Commit a0bd5ee8 authored by Skia's avatar Skia

Some more trombi pimping

parent a485ff1b
Pipeline #978 passed with stage
in 4 minutes and 22 seconds
......@@ -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 <>\n"
"Language-Team: AE info <>\n"
......@@ -590,7 +590,7 @@ msgstr "Effectuées"
#: counter/templates/counter/cash_summary_list.jinja:37 counter/
#: 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 "
#: trombi/templates/trombi/user_tools.jinja:44
msgid "Edit comment"
msgstr "Éditer le commentaire"
#: trombi/
#: trombi/
#, python-format
msgid "%(name)s (deadline: %(date)s)"
msgstr "%(name)s (date limite: %(date)s)"
#: trombi/
msgid "Select trombi"
msgstr "Choisir un trombi"
#: trombi/
#: trombi/
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/
#: trombi/
msgid "Personal email (not UTBM)"
msgstr "Email personnel (pas UTBM)"
#: trombi/
#: trombi/
msgid "Phone"
msgstr "Téléphone"
#: trombi/
#: trombi/
msgid "Native town"
msgstr "Ville d'origine"
#: trombi/
#: trombi/
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/
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/
#, 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>
{% set can_comment = trombi.subscription_deadline < and <= trombi.comments_deadline %}
{% if not can_comment %}
<p>{% trans %}You can not write comments at this date.{% endtrans %}</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>
{% endif %}
{% for u in user.trombi_user.trombi.users.exclude( %}
<div class="ib" style="border: solid 1px grey; text-align: center">
......@@ -30,12 +38,14 @@
<img src="{{ file }}" alt="" style="max-width: 100px">
<div>{{ u.user.get_display_name() }}</div>
{% if can_comment %}
{% set comment = u.received_comments.filter( %}
{% if comment %}
<a href="{{ url("trombi:edit_comment", }}">{% trans %}Edit comment{% endtrans %}</a>
{% else %}
<a href="{{ url("trombi:new_comment", }}">{% trans %}Comment{% endtrans %}</a>
{% endif %}
{% endif %}
{% endfor %}
......@@ -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()
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 <= 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 <
raise Http404(_("You can not write comment anymore, the deadline is "
"already passed."))
return modelform_factory(self.model, fields=self.fields,
'content': forms.widgets.Textarea(attrs={'maxlength': self.trombi.max_chars})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment