diff --git a/users/models.py b/users/models.py index 30acbf35..4867a3df 100644 --- a/users/models.py +++ b/users/models.py @@ -1,5 +1,6 @@ from django.db import models from django.forms import ModelForm +from django import forms class User(models.Model): STATE_ACTIVE = 0 @@ -23,7 +24,7 @@ class User(models.Model): state = models.IntegerField(choices=STATES, default=STATE_ACTIVE) def __str__(self): - return self.name + return self.pseudo class Right(models.Model): user = models.ForeignKey('User', on_delete=models.PROTECT) @@ -32,6 +33,9 @@ class Right(models.Model): class Meta: unique_together = ("user", "right") + def __str__(self): + return str(self.user) + " - " + str(self.right) + class School(models.Model): name = models.CharField(max_length=255) @@ -90,3 +94,10 @@ class RightForm(ModelForm): class Meta: model = Right fields = ['user', 'right'] + +class DelRightForm(ModelForm): + rights = forms.ModelMultipleChoiceField(queryset=Right.objects.all(), label="Droits actuels", widget=forms.CheckboxSelectMultiple) + + class Meta: + model = Right + exclude = ['user', 'right'] diff --git a/users/templates/users/sidebar.html b/users/templates/users/sidebar.html index 155ba0a4..edd57ccc 100644 --- a/users/templates/users/sidebar.html +++ b/users/templates/users/sidebar.html @@ -3,4 +3,6 @@ {% block sidebar %}
+ + {% endblock %} diff --git a/users/urls.py b/users/urls.py index 4a770010..31f97abd 100644 --- a/users/urls.py +++ b/users/urls.py @@ -8,6 +8,7 @@ urlpatterns = [ url(r'^state/(?P