Some more pimp in Trombi + translations

This commit is contained in:
Skia 2017-05-10 23:30:20 +02:00
parent 35f983131f
commit d913b8b64f
7 changed files with 379 additions and 183 deletions

View File

@ -11,6 +11,7 @@
{{ form.as_p() }} {{ form.as_p() }}
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p> <p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
</form> </form>
<h4>{% trans %}Trombi{% endtrans %}</h4>
{% if trombi_form %} {% if trombi_form %}
<form action="{{ url('trombi:user_tools') }}" method="post" enctype="multipart/form-data"> <form action="{{ url('trombi:user_tools') }}" method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
@ -18,7 +19,8 @@
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p> <p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
</form> </form>
{% else %} {% else %}
<p><a href="{{ url('trombi:user_tools') }}">Trombi tools</a></p> <p>{% trans trombi=user.trombi_user.trombi %}You already choose to be in that Trombi: {{ trombi }}.{% endtrans %}
<a href="{{ url('trombi:user_tools') }}">{% trans %}Go to my Trombi tools{% endtrans %}</a></p>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -106,6 +106,10 @@
<li><a href="{{ url('election:create') }}">{% trans %}Create a new election{% endtrans %}</a></li> <li><a href="{{ url('election:create') }}">{% trans %}Create a new election{% endtrans %}</a></li>
{%- endif -%} {%- endif -%}
</ul> </ul>
<h4>{% trans %}Other tools{% endtrans %}</h4>
<ul>
<li><a href="{{ url('trombi:user_tools') }}">{% trans %}Trombi tools{% endtrans %}</a></li>
</ul>
{% endblock %} {% endblock %}

File diff suppressed because it is too large Load Diff

View File

@ -55,9 +55,9 @@ class Trombi(models.Model):
"After this date, users subscribed will be allowed to comment on each other.")) "After this date, users subscribed will be allowed to comment on each other."))
comments_deadline = models.DateField(_('comments deadline'), comments_deadline = models.DateField(_('comments deadline'),
default=timezone.now, help_text=_("After this date, users won't be " default=timezone.now, help_text=_("After this date, users won't be "
"able to make comments anymore")) "able to make comments anymore."))
max_chars = models.IntegerField(_('maximum characters'), default=400, max_chars = models.IntegerField(_('maximum characters'), default=400,
help_text=_('maximum number of characters allowed in a comment')) help_text=_('Maximum number of characters allowed in a comment.'))
club = models.OneToOneField(Club, related_name='trombi') club = models.OneToOneField(Club, related_name='trombi')
objects = TrombiManager() objects = TrombiManager()
@ -98,6 +98,9 @@ class TrombiUser(models.Model):
scrub_pict = models.ImageField(upload_to='trombi', verbose_name=_("scrub pict"), null=True, blank=True, 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)")) help_text=_("The scrub picture you want in the trombi (warning: this picture may be published)"))
def __str__(self):
return str(self.user)
class TrombiComment(models.Model): class TrombiComment(models.Model):
""" """
This represent a comment given by someone to someone else in the same Trombi This represent a comment given by someone to someone else in the same Trombi
@ -111,3 +114,4 @@ class TrombiComment(models.Model):
if user.id == self.target.user.id: if user.id == self.target.user.id:
return False return False
return user.id == self.author.user.id or user.can_edit(self.author.trombi) return user.id == self.author.user.id or user.can_edit(self.author.trombi)

View File

@ -6,9 +6,9 @@
{% block content %} {% block content %}
<h2>{% trans club=object.club %}{{ club }}'s Trombi{% endtrans %}</h2> <h2>{% trans club=object.club %}{{ club }}'s Trombi{% endtrans %}</h2>
<a href="{{ url('trombi:edit', trombi_id=object.id) }}">Edit</a> <a href="{{ url('trombi:edit', trombi_id=object.id) }}">{% trans %}Edit{% endtrans %}</a>
<p>Subscription deadline: {{ object.subscription_deadline|date(DATETIME_FORMAT) }}</p> <p>{% trans %}Subscription deadline: {% endtrans %}{{ object.subscription_deadline|date(DATETIME_FORMAT) }}</p>
<p>Comment deadline: {{ object.comments_deadline|date(DATETIME_FORMAT) }}</p> <p>{% trans %}Comment deadline: {% endtrans %}{{ object.comments_deadline|date(DATETIME_FORMAT) }}</p>
<a href="#">Export</a> <a href="#">Export</a>
<hr> <hr>
<div> <div>
@ -24,7 +24,7 @@
<img src="{{ file }}" alt="" style="max-width: 100px"> <img src="{{ file }}" alt="" style="max-width: 100px">
</div> </div>
<div>{{ u.user.get_display_name() }}</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><a href="{{ url('trombi:delete_user', trombi_id=object.id, user_id=u.id) }}">{% trans %}Delete{% endtrans %}</a></div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>

View File

@ -14,8 +14,8 @@
</form> </form>
{% 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") }}">{% trans %}Edit my profile{% endtrans %}</a></p>
<p><a href="{{ url("trombi:pictures") }}">Edit my pictures</a></p> <p><a href="{{ url("trombi:pictures") }}">{% trans %}Edit my pictures{% endtrans %}</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) %}
@ -32,9 +32,9 @@
<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 %}
<a href="{{ url("trombi:edit_comment", comment_id=comment.id) }}">Edit comment</a> <a href="{{ url("trombi:edit_comment", comment_id=comment.id) }}">{% trans %}Edit comment{% endtrans %}</a>
{% else %} {% else %}
<a href="{{ url("trombi:new_comment", user_id=u.id) }}">Comment</a> <a href="{{ url("trombi:new_comment", user_id=u.id) }}">{% trans %}Comment{% endtrans %}</a>
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% endfor %}

View File

@ -72,7 +72,10 @@ class TrombiEditView(CanEditPropMixin, UpdateView):
template_name = 'core/edit.jinja' template_name = 'core/edit.jinja'
pk_url_kwarg = 'trombi_id' pk_url_kwarg = 'trombi_id'
class TrombiDetailView(CanEditMixin, DetailView): def get_success_url(self):
return super(TrombiEditView, self).get_success_url()+"?qn_success"
class TrombiDetailView(CanEditMixin, QuickNotifMixin, DetailView):
model = Trombi model = Trombi
template_name = 'trombi/detail.jinja' template_name = 'trombi/detail.jinja'
pk_url_kwarg = 'trombi_id' pk_url_kwarg = 'trombi_id'
@ -87,7 +90,7 @@ class TrombiDeleteUserView(CanEditPropMixin, SingleObjectMixin, RedirectView):
user = get_object_or_404(TrombiUser, id=self.kwargs['user_id']) user = get_object_or_404(TrombiUser, id=self.kwargs['user_id'])
user.delete() user.delete()
# See if we need to also delete the comments on the user, or if we keep them # See if we need to also delete the comments on the user, or if we keep them
return redirect(self.object.get_absolute_url()) return redirect(self.object.get_absolute_url()+"?qn_success")
# User side # User side
class UserTrombiForm(forms.Form): class UserTrombiForm(forms.Form):