mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 22:23:23 +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------------------------------*/
|
/*--------------------------------CONTENT------------------------------*/
|
||||||
|
|
||||||
|
.helptext {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
#quick_notif {
|
#quick_notif {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
margin: 0px auto;
|
margin: 0px auto;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
background: $primary-neutral-light-color;
|
background: $second-color;
|
||||||
li {
|
li {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
{% if not popup %}
|
{% if not popup %}
|
||||||
<nav>
|
<nav>
|
||||||
<a href="https://ae.utbm.fr/">{% trans %}Main{% endtrans %}</a>
|
<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('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
|
||||||
<a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a>
|
<a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a>
|
||||||
<a href="{{ url('forum:main') }}">{% trans %}Forum{% 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,
|
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
|
and trombi modules. It binds a User to a Trombi without needing to import
|
||||||
Trombi into the core.
|
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')
|
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)
|
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):
|
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>Subscription deadline: {{ object.subscription_deadline|date(DATETIME_FORMAT) }}</p>
|
||||||
<p>Comment deadline: {{ object.comments_deadline|date(DATETIME_FORMAT) }}</p>
|
<p>Comment deadline: {{ object.comments_deadline|date(DATETIME_FORMAT) }}</p>
|
||||||
<a href="#">Export</a>
|
<a href="#">Export</a>
|
||||||
<p>People:</p>
|
<hr>
|
||||||
<ul>
|
<div>
|
||||||
{% for u in object.users.all() %}
|
{% 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>
|
<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 %}
|
{% endfor %}
|
||||||
</ul>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -15,10 +15,20 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans trombi = user.trombi_user.trombi %}You are subscribed to the Trombi {{ trombi }}{% endtrans %}</p>
|
<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:profile") }}">Edit my profile</a></p>
|
||||||
|
<p><a href="{{ url("trombi:pictures") }}">Edit my pictures</a></p>
|
||||||
<hr>
|
<hr>
|
||||||
<div>
|
<div>
|
||||||
{% for u in user.trombi_user.trombi.users.exclude(id=user.trombi_user.id) %}
|
{% 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>
|
<div>{{ u.user.get_display_name() }}</div>
|
||||||
{% set comment = u.received_comments.filter(author__id=user.trombi_user.id).first() %}
|
{% set comment = u.received_comments.filter(author__id=user.trombi_user.id).first() %}
|
||||||
{% if comment %}
|
{% if comment %}
|
||||||
|
@ -35,5 +35,6 @@ urlpatterns = [
|
|||||||
url(r'^comment/(?P<comment_id>[0-9]+)/edit$', TrombiCommentEditView.as_view(), name='edit_comment'),
|
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'^tools$', UserTrombiToolsView.as_view(), name='user_tools'),
|
||||||
url(r'^profile$', UserTrombiEditProfileView.as_view(), name='profile'),
|
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()
|
kwargs['subscribe_form'] = UserTrombiForm()
|
||||||
return kwargs
|
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):
|
class UserTrombiEditProfileView(UpdateView):
|
||||||
model = User
|
model = User
|
||||||
form_class = modelform_factory(User,
|
form_class = modelform_factory(User,
|
||||||
@ -129,17 +140,20 @@ class UserTrombiEditProfileView(UpdateView):
|
|||||||
'parent_address': _("Native town"),
|
'parent_address': _("Native town"),
|
||||||
})
|
})
|
||||||
template_name = "core/edit.jinja"
|
template_name = "core/edit.jinja"
|
||||||
success_url = reverse_lazy('trombi:user_tools')
|
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self.request.user
|
return self.request.user
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse('trombi:user_tools')+"?qn_success"
|
||||||
|
|
||||||
class TrombiCommentFormView():
|
class TrombiCommentFormView():
|
||||||
"""
|
"""
|
||||||
Create/edit a trombi comment
|
Create/edit a trombi comment
|
||||||
"""
|
"""
|
||||||
model = TrombiComment
|
model = TrombiComment
|
||||||
fields = ['content']
|
fields = ['content']
|
||||||
|
template_name = 'trombi/comment.jinja'
|
||||||
|
|
||||||
def get_form_class(self):
|
def get_form_class(self):
|
||||||
self.trombi = self.request.user.trombi_user.trombi
|
self.trombi = self.request.user.trombi_user.trombi
|
||||||
@ -152,11 +166,17 @@ class TrombiCommentFormView():
|
|||||||
})
|
})
|
||||||
|
|
||||||
def get_success_url(self):
|
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):
|
class TrombiCommentCreateView(TrombiCommentFormView, CreateView):
|
||||||
template_name = 'core/create.jinja'
|
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
target = get_object_or_404(TrombiUser, id=self.kwargs['user_id'])
|
target = get_object_or_404(TrombiUser, id=self.kwargs['user_id'])
|
||||||
form.instance.author = self.request.user.trombi_user
|
form.instance.author = self.request.user.trombi_user
|
||||||
@ -165,6 +185,5 @@ class TrombiCommentCreateView(TrombiCommentFormView, CreateView):
|
|||||||
|
|
||||||
class TrombiCommentEditView(TrombiCommentFormView, CanViewMixin, UpdateView):
|
class TrombiCommentEditView(TrombiCommentFormView, CanViewMixin, UpdateView):
|
||||||
pk_url_kwarg = "comment_id"
|
pk_url_kwarg = "comment_id"
|
||||||
template_name = 'core/edit.jinja'
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user