mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Improve Trombi again with pictures, notifs, and style!
This commit is contained in:
parent
f2b2ff533d
commit
35f983131f
@ -193,11 +193,15 @@ nav {
|
||||
|
||||
/*--------------------------------CONTENT------------------------------*/
|
||||
|
||||
.helptext {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#quick_notif {
|
||||
width: 90%;
|
||||
margin: 0px auto;
|
||||
list-style-type: none;
|
||||
background: $primary-neutral-light-color;
|
||||
background: $second-color;
|
||||
li {
|
||||
padding: 10px;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@
|
||||
{% if not popup %}
|
||||
<nav>
|
||||
<a href="https://ae.utbm.fr/">{% trans %}Main{% endtrans %}</a>
|
||||
<a href="https://ae.utbm.fr/trombironch/">{% trans %}Matmatronch{% endtrans %}</a>
|
||||
<a href="https://ae.utbm.fr/matmatronch/">{% trans %}Matmatronch{% endtrans %}</a>
|
||||
<a href="{{ url('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
|
||||
<a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a>
|
||||
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
||||
|
24
trombi/migrations/0002_auto_20170510_2229.py
Normal file
24
trombi/migrations/0002_auto_20170510_2229.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('trombi', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='trombiuser',
|
||||
name='profile_pict',
|
||||
field=models.ImageField(null=True, blank=True, help_text='The profile picture you want in the trombi (warning: this picture may be published)', verbose_name='profile pict', upload_to='trombi'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='trombiuser',
|
||||
name='scrub_pict',
|
||||
field=models.ImageField(null=True, blank=True, help_text='The scrub picture you want in the trombi (warning: this picture may be published)', verbose_name='scrub pict', upload_to='trombi'),
|
||||
),
|
||||
]
|
@ -88,9 +88,15 @@ class TrombiUser(models.Model):
|
||||
This class is only here to avoid cross references between the core, club,
|
||||
and trombi modules. It binds a User to a Trombi without needing to import
|
||||
Trombi into the core.
|
||||
It also adds the pictures to the profile without needing all the security
|
||||
like the other SithFiles.
|
||||
"""
|
||||
user = models.OneToOneField(User, verbose_name=_("trombi user"), related_name='trombi_user')
|
||||
trombi = models.ForeignKey(Trombi, verbose_name=_("trombi"), related_name='users', blank=True, null=True, on_delete=models.SET_NULL)
|
||||
profile_pict = models.ImageField(upload_to='trombi', verbose_name=_("profile pict"), null=True, blank=True,
|
||||
help_text=_("The profile picture you want in the trombi (warning: this picture may be published)"))
|
||||
scrub_pict = models.ImageField(upload_to='trombi', verbose_name=_("scrub pict"), null=True, blank=True,
|
||||
help_text=_("The scrub picture you want in the trombi (warning: this picture may be published)"))
|
||||
|
||||
class TrombiComment(models.Model):
|
||||
"""
|
||||
|
31
trombi/templates/trombi/comment.jinja
Normal file
31
trombi/templates/trombi/comment.jinja
Normal file
@ -0,0 +1,31 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}Comment{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans %}Comment{% endtrans %}</h2>
|
||||
<div style="width: 400px; margin: auto; border: solid 1px grey; text-align: center">
|
||||
{% set file = None %}
|
||||
{% if target.profile_pict %}
|
||||
{% set file = target.profile_pict.url %}
|
||||
{% else %}
|
||||
{% set file = static('core/img/na.gif') %}
|
||||
{% endif %}
|
||||
<div style="max-width: 300px; margin: auto;">
|
||||
<img src="{{ file }}" alt="" style="max-width: 300px">
|
||||
</div>
|
||||
<div>
|
||||
{{ target.user.get_display_name() }}
|
||||
</div>
|
||||
</div>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p() }}
|
||||
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@ -10,10 +10,22 @@
|
||||
<p>Subscription deadline: {{ object.subscription_deadline|date(DATETIME_FORMAT) }}</p>
|
||||
<p>Comment deadline: {{ object.comments_deadline|date(DATETIME_FORMAT) }}</p>
|
||||
<a href="#">Export</a>
|
||||
<p>People:</p>
|
||||
<ul>
|
||||
{% for u in object.users.all() %}
|
||||
<li>{{ u.user.get_display_name() }} - <a href="{{ url('trombi:delete_user', trombi_id=object.id, user_id=u.id) }}">Delete</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<hr>
|
||||
<div>
|
||||
{% for u in object.users.all() %}
|
||||
<div class="ib" style="border: solid 1px grey; text-align: center">
|
||||
{% set file = None %}
|
||||
{% if u.profile_pict %}
|
||||
{% set file = u.profile_pict.url %}
|
||||
{% else %}
|
||||
{% set file = static('core/img/na.gif') %}
|
||||
{% endif %}
|
||||
<div style="max-width: 100px; margin: auto;">
|
||||
<img src="{{ file }}" alt="" style="max-width: 100px">
|
||||
</div>
|
||||
<div>{{ u.user.get_display_name() }}</div>
|
||||
<div><a href="{{ url('trombi:delete_user', trombi_id=object.id, user_id=u.id) }}">Delete</a></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -15,10 +15,20 @@
|
||||
{% else %}
|
||||
<p>{% trans trombi = user.trombi_user.trombi %}You are subscribed to the Trombi {{ trombi }}{% endtrans %}</p>
|
||||
<p><a href="{{ url("trombi:profile") }}">Edit my profile</a></p>
|
||||
<p><a href="{{ url("trombi:pictures") }}">Edit my pictures</a></p>
|
||||
<hr>
|
||||
<div>
|
||||
{% for u in user.trombi_user.trombi.users.exclude(id=user.trombi_user.id) %}
|
||||
<div class="ib">
|
||||
<div class="ib" style="border: solid 1px grey; text-align: center">
|
||||
{% set file = None %}
|
||||
{% if u.profile_pict %}
|
||||
{% set file = u.profile_pict.url %}
|
||||
{% else %}
|
||||
{% set file = static('core/img/na.gif') %}
|
||||
{% endif %}
|
||||
<div style="max-width: 100px; margin: auto;">
|
||||
<img src="{{ file }}" alt="" style="max-width: 100px">
|
||||
</div>
|
||||
<div>{{ u.user.get_display_name() }}</div>
|
||||
{% set comment = u.received_comments.filter(author__id=user.trombi_user.id).first() %}
|
||||
{% if comment %}
|
||||
|
@ -35,5 +35,6 @@ urlpatterns = [
|
||||
url(r'^comment/(?P<comment_id>[0-9]+)/edit$', TrombiCommentEditView.as_view(), name='edit_comment'),
|
||||
url(r'^tools$', UserTrombiToolsView.as_view(), name='user_tools'),
|
||||
url(r'^profile$', UserTrombiEditProfileView.as_view(), name='profile'),
|
||||
url(r'^pictures$', UserTrombiEditPicturesView.as_view(), name='pictures'),
|
||||
]
|
||||
|
||||
|
@ -118,6 +118,17 @@ class UserTrombiToolsView(QuickNotifMixin, TemplateView):
|
||||
kwargs['subscribe_form'] = UserTrombiForm()
|
||||
return kwargs
|
||||
|
||||
class UserTrombiEditPicturesView(UpdateView):
|
||||
model = TrombiUser
|
||||
fields = ['profile_pict', 'scrub_pict']
|
||||
template_name = "core/edit.jinja"
|
||||
|
||||
def get_object(self):
|
||||
return self.request.user.trombi_user
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('trombi:user_tools')+"?qn_success"
|
||||
|
||||
class UserTrombiEditProfileView(UpdateView):
|
||||
model = User
|
||||
form_class = modelform_factory(User,
|
||||
@ -129,17 +140,20 @@ class UserTrombiEditProfileView(UpdateView):
|
||||
'parent_address': _("Native town"),
|
||||
})
|
||||
template_name = "core/edit.jinja"
|
||||
success_url = reverse_lazy('trombi:user_tools')
|
||||
|
||||
def get_object(self):
|
||||
return self.request.user
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('trombi:user_tools')+"?qn_success"
|
||||
|
||||
class TrombiCommentFormView():
|
||||
"""
|
||||
Create/edit a trombi comment
|
||||
"""
|
||||
model = TrombiComment
|
||||
fields = ['content']
|
||||
template_name = 'trombi/comment.jinja'
|
||||
|
||||
def get_form_class(self):
|
||||
self.trombi = self.request.user.trombi_user.trombi
|
||||
@ -152,11 +166,17 @@ class TrombiCommentFormView():
|
||||
})
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('trombi:user_tools')
|
||||
return reverse('trombi:user_tools')+"?qn_success"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(TrombiCommentFormView, self).get_context_data(**kwargs)
|
||||
if 'user_id' in self.kwargs.keys():
|
||||
kwargs['target'] = get_object_or_404(TrombiUser, id=self.kwargs['user_id'])
|
||||
else:
|
||||
kwargs['target'] = self.object.target
|
||||
return kwargs
|
||||
|
||||
class TrombiCommentCreateView(TrombiCommentFormView, CreateView):
|
||||
template_name = 'core/create.jinja'
|
||||
|
||||
def form_valid(self, form):
|
||||
target = get_object_or_404(TrombiUser, id=self.kwargs['user_id'])
|
||||
form.instance.author = self.request.user.trombi_user
|
||||
@ -165,6 +185,5 @@ class TrombiCommentCreateView(TrombiCommentFormView, CreateView):
|
||||
|
||||
class TrombiCommentEditView(TrombiCommentFormView, CanViewMixin, UpdateView):
|
||||
pk_url_kwarg = "comment_id"
|
||||
template_name = 'core/edit.jinja'
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user