mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
trombi: allow admins to manually add users
Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
parent
a108291422
commit
de96c07ba8
@ -12,6 +12,13 @@
|
|||||||
<p>{% trans %}Comment deadline: {% endtrans %}{{ 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>
|
||||||
|
<h4>{% trans %}Add user{% endtrans %}</h4>
|
||||||
|
<form action="" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p() }}
|
||||||
|
<input type="submit" value="{% trans %}Add{% endtrans %}" />
|
||||||
|
</form>
|
||||||
|
<hr>
|
||||||
<div>
|
<div>
|
||||||
{% for u in object.users.order_by('user__nick_name') %}
|
{% for u in object.users.order_by('user__nick_name') %}
|
||||||
<div class="ib" style="border: solid 1px grey; text-align: center">
|
<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.conf import settings
|
||||||
from django.forms.models import modelform_factory
|
from django.forms.models import modelform_factory
|
||||||
|
|
||||||
|
from ajax_select.fields import AutoCompleteSelectField
|
||||||
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from trombi.models import Trombi, TrombiUser, TrombiComment, TrombiClubMembership
|
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"
|
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):
|
class TrombiDetailView(CanEditMixin, QuickNotifMixin, TrombiTabsMixin, 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'
|
||||||
current_tab = "admin_tools"
|
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):
|
class TrombiDeleteUserView(CanEditPropMixin, TrombiTabsMixin, DeleteView):
|
||||||
model = TrombiUser
|
model = TrombiUser
|
||||||
|
Loading…
Reference in New Issue
Block a user