diff --git a/trombi/templates/trombi/detail.jinja b/trombi/templates/trombi/detail.jinja
index 25d1859a..10492798 100644
--- a/trombi/templates/trombi/detail.jinja
+++ b/trombi/templates/trombi/detail.jinja
@@ -12,6 +12,13 @@
{% trans %}Comment deadline: {% endtrans %}{{ object.comments_deadline|date(DATETIME_FORMAT) }}
{% for u in object.users.order_by('user__nick_name') %}
diff --git a/trombi/views.py b/trombi/views.py
index bcf3b449..b493db35 100644
--- a/trombi/views.py
+++ b/trombi/views.py
@@ -32,6 +32,8 @@ from django import forms
from django.conf import settings
from django.forms.models import modelform_factory
+from ajax_select.fields import AutoCompleteSelectField
+
from datetime import date
from trombi.models import Trombi, TrombiUser, TrombiComment, TrombiClubMembership
@@ -118,12 +120,29 @@ class TrombiEditView(CanEditPropMixin, TrombiTabsMixin, UpdateView):
return super(TrombiEditView, self).get_success_url() + "?qn_success"
+class AddUserForm(forms.Form):
+ user = AutoCompleteSelectField('users', required=True, label=_("Select user"), help_text=None)
+
class TrombiDetailView(CanEditMixin, QuickNotifMixin, TrombiTabsMixin, DetailView):
model = Trombi
template_name = 'trombi/detail.jinja'
pk_url_kwarg = 'trombi_id'
current_tab = "admin_tools"
+ def post(self, request, *args, **kwargs):
+ self.object = self.get_object()
+ form = AddUserForm(request.POST)
+ if form.is_valid():
+ try:
+ TrombiUser(user=form.cleaned_data['user'], trombi=self.object).save()
+ except: pass # We don't care about duplicate keys
+ return super(TrombiDetailView, self).get(request, *args, **kwargs)
+
+ def get_context_data(self, **kwargs):
+ kwargs = super(TrombiDetailView, self).get_context_data(**kwargs)
+ kwargs['form'] = AddUserForm()
+ return kwargs
+
class TrombiDeleteUserView(CanEditPropMixin, TrombiTabsMixin, DeleteView):
model = TrombiUser