Commit de96c07b authored by Skia's avatar Skia 🤘
Browse files

trombi: allow admins to manually add users

Signed-off-by: Skia's avatarSkia <>
parent a1082914
Pipeline #1084 passed with stage
in 4 minutes and 53 seconds
......@@ -12,6 +12,13 @@
<p>{% trans %}Comment deadline: {% endtrans %}{{ object.comments_deadline|date(DATETIME_FORMAT) }}</p>
<a href="#">Export</a>
<h4>{% trans %}Add user{% endtrans %}</h4>
<form action="" method="post">
{% csrf_token %}
{{ form.as_p() }}
<input type="submit" value="{% trans %}Add{% endtrans %}" />
{% for u in object.users.order_by('user__nick_name') %}
<div class="ib" style="border: solid 1px grey; text-align: center">
......@@ -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():
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
Supports Markdown
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