mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Some more trombi pimping
This commit is contained in:
parent
a485ff1b8e
commit
a0bd5ee8ff
@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-05-10 23:26+0200\n"
|
||||
"POT-Creation-Date: 2017-05-11 18:32+0200\n"
|
||||
"PO-Revision-Date: 2016-07-18\n"
|
||||
"Last-Translator: Skia <skia@libskia.so>\n"
|
||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||
@ -590,7 +590,7 @@ msgstr "Effectuées"
|
||||
#: counter/templates/counter/cash_summary_list.jinja:37 counter/views.py:798
|
||||
#: trombi/templates/trombi/comment.jinja:4
|
||||
#: trombi/templates/trombi/comment.jinja:8
|
||||
#: trombi/templates/trombi/user_tools.jinja:37
|
||||
#: trombi/templates/trombi/user_tools.jinja:46
|
||||
msgid "Comment"
|
||||
msgstr "Commentaire"
|
||||
|
||||
@ -4430,15 +4430,31 @@ msgstr "Éditer mon profil"
|
||||
msgid "Edit my pictures"
|
||||
msgstr "Éditer mes photos"
|
||||
|
||||
#: trombi/templates/trombi/user_tools.jinja:35
|
||||
#: trombi/templates/trombi/user_tools.jinja:23
|
||||
msgid "You can not write comments at this date."
|
||||
msgstr "Vous ne pouvez pas commenter à cette date."
|
||||
|
||||
#: trombi/templates/trombi/user_tools.jinja:25
|
||||
msgid ""
|
||||
"Comments are only allowed between %(start)s (excluded) and %(end)s (included)"
|
||||
msgstr ""
|
||||
"Les commentaires sont autorisés entre le %(start)s (exclu) et le %(end)s "
|
||||
"(inclu)"
|
||||
|
||||
#: trombi/templates/trombi/user_tools.jinja:44
|
||||
msgid "Edit comment"
|
||||
msgstr "Éditer le commentaire"
|
||||
|
||||
#: trombi/views.py:94
|
||||
#: trombi/views.py:101
|
||||
#, python-format
|
||||
msgid "%(name)s (deadline: %(date)s)"
|
||||
msgstr "%(name)s (date limite: %(date)s)"
|
||||
|
||||
#: trombi/views.py:104
|
||||
msgid "Select trombi"
|
||||
msgstr "Choisir un trombi"
|
||||
|
||||
#: trombi/views.py:95
|
||||
#: trombi/views.py:105
|
||||
msgid ""
|
||||
"This allows you to subscribe to a Trombi. Be aware that you can subscribe "
|
||||
"only once, so don't play with that, or you will expose yourself to the "
|
||||
@ -4448,19 +4464,31 @@ msgstr ""
|
||||
"pouvez vous inscrire qu'à un seul Trombi, donc ne jouez pas avec cet option "
|
||||
"ou vous encourerez la colère des admins!"
|
||||
|
||||
#: trombi/views.py:138
|
||||
#: trombi/views.py:151
|
||||
msgid "Personal email (not UTBM)"
|
||||
msgstr "Email personnel (pas UTBM)"
|
||||
|
||||
#: trombi/views.py:139
|
||||
#: trombi/views.py:152
|
||||
msgid "Phone"
|
||||
msgstr "Téléphone"
|
||||
|
||||
#: trombi/views.py:140
|
||||
#: trombi/views.py:153
|
||||
msgid "Native town"
|
||||
msgstr "Ville d'origine"
|
||||
|
||||
#: trombi/views.py:165
|
||||
#: trombi/views.py:174
|
||||
msgid ""
|
||||
"You can not yet write comment, you must wait for the subscription deadline "
|
||||
"to be passed."
|
||||
msgstr ""
|
||||
"Vous ne pouvez pas encore écrire de commentaires, vous devez attendre la fin "
|
||||
"des inscriptions"
|
||||
|
||||
#: trombi/views.py:177
|
||||
msgid "You can not write comment anymore, the deadline is already passed."
|
||||
msgstr "Vous ne pouvez plus écrire de commentaires, la date est passée."
|
||||
|
||||
#: trombi/views.py:184
|
||||
#, python-format
|
||||
msgid "Maximum characters: %(max_length)s"
|
||||
msgstr "Nombre de caractères max: %(max_length)s"
|
||||
|
@ -17,6 +17,14 @@
|
||||
<p><a href="{{ url("trombi:profile") }}">{% trans %}Edit my profile{% endtrans %}</a></p>
|
||||
<p><a href="{{ url("trombi:pictures") }}">{% trans %}Edit my pictures{% endtrans %}</a></p>
|
||||
<hr>
|
||||
{% set can_comment = trombi.subscription_deadline < date.today() and
|
||||
date.today() <= trombi.comments_deadline %}
|
||||
{% if not can_comment %}
|
||||
<p>{% trans %}You can not write comments at this date.{% endtrans %}</p>
|
||||
<p>
|
||||
{% trans start=trombi.subscription_deadline|date(DATE_FORMAT), end=trombi.comments_deadline|date(DATE_FORMAT) %}Comments are only allowed between {{ start }} (excluded) and {{ end }} (included){% endtrans %}</p>
|
||||
<hr>
|
||||
{% endif %}
|
||||
<div>
|
||||
{% for u in user.trombi_user.trombi.users.exclude(id=user.trombi_user.id) %}
|
||||
<div class="ib" style="border: solid 1px grey; text-align: center">
|
||||
@ -30,12 +38,14 @@
|
||||
<img src="{{ file }}" alt="" style="max-width: 100px">
|
||||
</div>
|
||||
<div>{{ u.user.get_display_name() }}</div>
|
||||
{% if can_comment %}
|
||||
{% set comment = u.received_comments.filter(author__id=user.trombi_user.id).first() %}
|
||||
{% if comment %}
|
||||
<a href="{{ url("trombi:edit_comment", comment_id=comment.id) }}">{% trans %}Edit comment{% endtrans %}</a>
|
||||
{% else %}
|
||||
<a href="{{ url("trombi:new_comment", user_id=u.id) }}">{% trans %}Comment{% endtrans %}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
@ -22,6 +22,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from django.http import Http404
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.core.urlresolvers import reverse_lazy, reverse
|
||||
from django.views.generic import ListView, DetailView, RedirectView, TemplateView
|
||||
@ -30,6 +31,8 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from django import forms
|
||||
from django.forms.models import modelform_factory
|
||||
|
||||
from datetime import date
|
||||
|
||||
from trombi.models import Trombi, TrombiUser, TrombiComment
|
||||
from core.views.forms import SelectFile, SelectDate
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, CanCreateMixin, QuickNotifMixin
|
||||
@ -93,8 +96,12 @@ class TrombiDeleteUserView(CanEditPropMixin, SingleObjectMixin, RedirectView):
|
||||
return redirect(self.object.get_absolute_url()+"?qn_success")
|
||||
|
||||
# User side
|
||||
class TrombiModelChoiceField(forms.ModelChoiceField):
|
||||
def label_from_instance(self, obj):
|
||||
return _("%(name)s (deadline: %(date)s)") % {'name': str(obj), 'date': str(obj.subscription_deadline)}
|
||||
|
||||
class UserTrombiForm(forms.Form):
|
||||
trombi = forms.ModelChoiceField(Trombi.availables.all(), required=False, label=_("Select trombi"),
|
||||
trombi = TrombiModelChoiceField(Trombi.availables.all(), required=False, label=_("Select trombi"),
|
||||
help_text=_("This allows you to subscribe to a Trombi. "
|
||||
"Be aware that you can subscribe only once, so don't play with that, "
|
||||
"or you will expose yourself to the admins' wrath!"))
|
||||
@ -119,6 +126,9 @@ class UserTrombiToolsView(QuickNotifMixin, TemplateView):
|
||||
kwargs['user'] = self.request.user
|
||||
if not hasattr(self.request.user, 'trombi_user'):
|
||||
kwargs['subscribe_form'] = UserTrombiForm()
|
||||
else:
|
||||
kwargs['trombi'] = self.request.user.trombi_user.trombi
|
||||
kwargs['date'] = date
|
||||
return kwargs
|
||||
|
||||
class UserTrombiEditPicturesView(UpdateView):
|
||||
@ -160,6 +170,12 @@ class TrombiCommentFormView():
|
||||
|
||||
def get_form_class(self):
|
||||
self.trombi = self.request.user.trombi_user.trombi
|
||||
if date.today() <= self.trombi.subscription_deadline:
|
||||
raise Http404(_("You can not yet write comment, you must wait for "
|
||||
"the subscription deadline to be passed."))
|
||||
if self.trombi.comments_deadline < date.today():
|
||||
raise Http404(_("You can not write comment anymore, the deadline is "
|
||||
"already passed."))
|
||||
return modelform_factory(self.model, fields=self.fields,
|
||||
widgets={
|
||||
'content': forms.widgets.Textarea(attrs={'maxlength': self.trombi.max_chars})
|
||||
|
Loading…
Reference in New Issue
Block a user