From c58d47815133f286f27de2f498c17ac691e184cd Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Wed, 24 Oct 2012 11:39:27 +0200 Subject: [PATCH 1/8] rename render_to_forbitten to render_to_forbidden. #370 --- openslides/utils/utils.py | 4 ++-- openslides/utils/views.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openslides/utils/utils.py b/openslides/utils/utils.py index 6d14b35a6..41aaf7544 100644 --- a/openslides/utils/utils.py +++ b/openslides/utils/utils.py @@ -101,13 +101,13 @@ def permission_required(perm, login_url=None): if request.user.has_perm(perm): return func(request, *args, **kw) if request.user.is_authenticated(): - return render_to_forbitten(request) + return render_to_forbidden(request) return redirect(reverse('user_login')) return wrapper return renderer -def render_to_forbitten(request, error= +def render_to_forbidden(request, error= ugettext_lazy("Sorry, you have no rights to see this page.")): return HttpResponseForbidden(render_to_string('403.html', {'error': error}, context_instance=RequestContext(request))) diff --git a/openslides/utils/views.py b/openslides/utils/views.py index becdbfc8b..be40f9062 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -52,7 +52,7 @@ from django.views.generic.list import TemplateResponseMixin from openslides.config.models import config -from openslides.utils.utils import render_to_forbitten, html_strong +from openslides.utils.utils import render_to_forbidden, html_strong from openslides.utils.signals import template_manipulation from openslides.utils.pdf import firstPage, laterPages @@ -93,7 +93,7 @@ class PermissionMixin(object): return HttpResponseRedirect("%s?next=%s" % (settings.LOGIN_URL, path)) else: - return render_to_forbitten(request) + return render_to_forbidden(request) return _View.dispatch(self, request, *args, **kwargs) From f99fdc69817cb1931371fc6f38323b3237cbd468 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Wed, 24 Oct 2012 12:00:51 +0200 Subject: [PATCH 2/8] fixed inital_data --- initial_data.json | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/initial_data.json b/initial_data.json index 5f7c8e30c..9b25d1a34 100644 --- a/initial_data.json +++ b/initial_data.json @@ -11,14 +11,14 @@ "item" ], [ - "can_create_application", - "application", - "application" + "can_create_motion", + "motion", + "motion" ], [ - "can_see_application", - "application", - "application" + "can_see_motion", + "motion", + "motion" ], [ "can_nominate_other", @@ -60,19 +60,19 @@ "item" ], [ - "can_create_application", - "application", - "application" + "can_create_motion", + "motion", + "motion" ], [ - "can_see_application", - "application", - "application" + "can_see_motion", + "motion", + "motion" ], [ - "can_support_application", - "application", - "application" + "can_support_motion", + "motion", + "motion" ], [ "can_nominate_other", @@ -119,19 +119,19 @@ "item" ], [ - "can_create_application", - "application", - "application" + "can_create_motion", + "motion", + "motion" ], [ - "can_manage_application", - "application", - "application" + "can_manage_motion", + "motion", + "motion" ], [ - "can_see_application", - "application", - "application" + "can_see_motion", + "motion", + "motion" ], [ "can_manage_assignment", From 3e1938941fa8a2e7bcd063fc05892b6a67691c56 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Wed, 24 Oct 2012 12:15:29 +0200 Subject: [PATCH 3/8] Append a default class for the person-api. Also fixed the assignment-ballot-paper for group-persons --- openslides/assignment/views.py | 8 ++++---- openslides/participant/models.py | 15 ++++++++------ openslides/utils/person/__init__.py | 3 ++- openslides/utils/person/api.py | 31 +++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py index 68f561c87..a65d10997 100644 --- a/openslides/assignment/views.py +++ b/openslides/assignment/views.py @@ -430,7 +430,7 @@ class AssignmentPDF(PDFView): for candidate, poll_list in vote_results.iteritems(): row = [] - candidate_string = candidate.user.get_full_name() + candidate_string = candidate.clean_name if candidate in elected_candidates: candidate_string = "* " + candidate_string if candidate.category: @@ -565,7 +565,7 @@ class AssignmentPollPDF(PDFView): if self.poll.yesnoabstain: for option in options: candidate = option.candidate - cell.append(Paragraph(candidate.user.get_full_name(), + cell.append(Paragraph(candidate.clean_name, stylesheet['Ballot_option_name'])) if candidate.name_suffix: cell.append(Paragraph("(%s)" % candidate.name_suffix, @@ -591,9 +591,9 @@ class AssignmentPollPDF(PDFView): else: for option in options: candidate = option.candidate - cell.append(Paragraph(circle + candidate.user.get_full_name(), + cell.append(Paragraph(circle + candidate.clean_name, stylesheet['Ballot_option_name'])) - if candidate.category: + if candidate.name_suffix: cell.append(Paragraph("(%s)" % candidate.category, stylesheet['Ballot_option_group_right'])) else: diff --git a/openslides/participant/models.py b/openslides/participant/models.py index 42b965f69..2cce07709 100644 --- a/openslides/participant/models.py +++ b/openslides/participant/models.py @@ -16,14 +16,14 @@ from django.db.models import signals from django.dispatch import receiver from django.utils.translation import ugettext_lazy as _, ugettext_noop -from openslides.utils.person import PersonMixin +from openslides.utils.person import PersonMixin, Person from openslides.utils.person.signals import receive_persons from openslides.config.models import config from openslides.config.signals import default_config_value -class User(DjangoUser, PersonMixin): +class User(DjangoUser, PersonMixin, Person): person_prefix = 'user' GENDER_CHOICES = ( ('male', _('Male')), @@ -56,6 +56,10 @@ class User(DjangoUser, PersonMixin): max_length=100, null=True, blank=True, verbose_name=_("Default password")) + @property + def clean_name(self): + return self.get_full_name() or self.username + def get_name_suffix(self): return self.category @@ -88,10 +92,9 @@ class User(DjangoUser, PersonMixin): return ('user_delete', [str(self.id)]) def __unicode__(self): - name = self.get_full_name() or self.username if self.name_suffix: - return u"%s (%s)" % (name, self.name_suffix) - return u"%s" % name + return u"%s (%s)" % (self.clean_name, self.name_suffix) + return u"%s" % self.clean_name class Meta: # Rename permissions @@ -103,7 +106,7 @@ class User(DjangoUser, PersonMixin): ordering = ('last_name',) -class Group(DjangoGroup, PersonMixin): +class Group(DjangoGroup, PersonMixin, Person): person_prefix = 'group' django_group = models.OneToOneField(DjangoGroup, editable=False, parent_link=True) diff --git a/openslides/utils/person/__init__.py b/openslides/utils/person/__init__.py index cc983caf9..7a69e8f25 100644 --- a/openslides/utils/person/__init__.py +++ b/openslides/utils/person/__init__.py @@ -11,7 +11,8 @@ """ from openslides.utils.person.signals import receive_persons -from openslides.utils.person.api import generate_person_id, get_person, Persons +from openslides.utils.person.api import (generate_person_id, get_person, + Person, Persons) from openslides.utils.person.forms import PersonFormField, MultiplePersonFormField from openslides.utils.person.models import PersonField, PersonMixin diff --git a/openslides/utils/person/api.py b/openslides/utils/person/api.py index 49d901f28..5c842dea2 100644 --- a/openslides/utils/person/api.py +++ b/openslides/utils/person/api.py @@ -13,6 +13,37 @@ from openslides.utils.person.signals import receive_persons +class Person(object): + """ + Meta-class for all person objects + """ + def person_id(self): + """ + Return an id for representation of ths person. Has to be unique. + """ + raise NotImplementedError('Any person object needs a person_id') + + def __repr__(self): + """ + Return a string for this person. + """ + return str(self.person_id) + + @property + def clean_name(self): + """ + Return the name of this person without a suffix + """ + return unicode(self) + + @property + def name_suffix(self): + """ + Return a suffix for the person-name. + """ + return '' + + class Persons(object): """ A Storage for a multiplicity of different Person-Objects. From 56b9e831c838be5e71bc94f63bf4354e7708c754 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Wed, 24 Oct 2012 12:21:44 +0200 Subject: [PATCH 4/8] Allowd access to the dashboard per default. #361 --- initial_data.json | 20 ++++++++++++++++++++ openslides/config/views.py | 5 +++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/initial_data.json b/initial_data.json index 9b25d1a34..a0d786baf 100644 --- a/initial_data.json +++ b/initial_data.json @@ -44,6 +44,11 @@ "can_see_projector", "projector", "projectorslide" + ], + [ + "can_see_dashboard", + "projector", + "projectorslide" ] ] } @@ -98,6 +103,11 @@ "can_see_projector", "projector", "projectorslide" + ], + [ + "can_see_dashboard", + "projector", + "projectorslide" ] ] } @@ -177,6 +187,11 @@ "can_see_projector", "projector", "projectorslide" + ], + [ + "can_see_dashboard", + "projector", + "projectorslide" ] ] } @@ -206,6 +221,11 @@ "can_see_projector", "projector", "projectorslide" + ], + [ + "can_see_dashboard", + "projector", + "projectorslide" ] ] } diff --git a/openslides/config/views.py b/openslides/config/views.py index 19b7b9953..908ac7db6 100644 --- a/openslides/config/views.py +++ b/openslides/config/views.py @@ -66,8 +66,9 @@ class GeneralConfig(FormView): try: anonymous = Group.objects.get(name='Anonymous') except Group.DoesNotExist: - default_perms = [u'can_see_agenda', u'can_see_projector', - u'can_see_motion', u'can_see_assignment'] + default_perms = ['can_see_agenda', 'can_see_projector', + 'can_see_motion', 'can_see_assignment', + 'can_see_dashboard'] anonymous = Group() anonymous.name = 'Anonymous' anonymous.save() From 57d591fee88b0b3ce563cc01a9504ca64f691a64 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Wed, 24 Oct 2012 12:30:45 +0200 Subject: [PATCH 5/8] Renamed category to detail --- openslides/assignment/views.py | 6 +++--- openslides/participant/forms.py | 4 ++-- openslides/participant/models.py | 14 +++++++------- .../templates/participant/overview.html | 14 +++++++------- openslides/participant/tests.py | 6 +++--- openslides/participant/views.py | 18 +++++++++--------- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py index a65d10997..0c1e1f969 100644 --- a/openslides/assignment/views.py +++ b/openslides/assignment/views.py @@ -433,8 +433,8 @@ class AssignmentPDF(PDFView): candidate_string = candidate.clean_name if candidate in elected_candidates: candidate_string = "* " + candidate_string - if candidate.category: - candidate_string += "\n(%s)" % candidate.category + if candidate.name_suffix: + candidate_string += "\n(%s)" % candidate.name_suffix row.append(candidate_string) for vote in poll_list: if vote == None: @@ -594,7 +594,7 @@ class AssignmentPollPDF(PDFView): cell.append(Paragraph(circle + candidate.clean_name, stylesheet['Ballot_option_name'])) if candidate.name_suffix: - cell.append(Paragraph("(%s)" % candidate.category, + cell.append(Paragraph("(%s)" % candidate.name_suffix, stylesheet['Ballot_option_group_right'])) else: cell.append(Paragraph(" ", diff --git a/openslides/participant/forms.py b/openslides/participant/forms.py index 4687432fe..153285d8f 100644 --- a/openslides/participant/forms.py +++ b/openslides/participant/forms.py @@ -27,7 +27,7 @@ class UserCreateForm(forms.ModelForm, CssClassMixin): class Meta: model = User - fields = ('first_name', 'last_name', 'is_active', 'groups', 'category', + fields = ('first_name', 'last_name', 'is_active', 'groups', 'detail', 'gender', 'type', 'committee', 'comment', 'default_password') @@ -35,7 +35,7 @@ class UserUpdateForm(UserCreateForm): class Meta: model = User fields = ('username', 'first_name', 'last_name', 'is_active', 'groups', - 'category', 'gender', 'type', 'committee', 'comment', + 'detail', 'gender', 'type', 'committee', 'comment', 'default_password') diff --git a/openslides/participant/models.py b/openslides/participant/models.py index 2cce07709..cabb54b7a 100644 --- a/openslides/participant/models.py +++ b/openslides/participant/models.py @@ -37,8 +37,8 @@ class User(DjangoUser, PersonMixin, Person): ) django_user = models.OneToOneField(DjangoUser, editable=False, parent_link=True) - category = models.CharField( - max_length=100, null=True, blank=True, verbose_name=_("Category"), + detail = models.CharField( + max_length=100, blank=True, default='', verbose_name=_("Detail"), help_text=_('Will be shown behind the name.')) gender = models.CharField( max_length=50, choices=GENDER_CHOICES, blank=True, @@ -47,13 +47,13 @@ class User(DjangoUser, PersonMixin, Person): max_length=100, choices=TYPE_CHOICES, blank=True, verbose_name=_("Typ"), help_text=_('Only for filter the userlist.')) committee = models.CharField( - max_length=100, null=True, blank=True, verbose_name=_("Committee"), + max_length=100, blank=True, default='', verbose_name=_("Committee"), help_text=_('Only for filter the userlist.')) comment = models.TextField( - null=True, blank=True, verbose_name=_('Comment'), + blank=True, default='', verbose_name=_('Comment'), help_text=_('Only for notes.')) default_password = models.CharField( - max_length=100, null=True, blank=True, + max_length=100, blank=True, default='', verbose_name=_("Default password")) @property @@ -61,10 +61,10 @@ class User(DjangoUser, PersonMixin, Person): return self.get_full_name() or self.username def get_name_suffix(self): - return self.category + return self.detail def set_name_suffix(self, value): - self.category = value + self.detail = value name_suffix = property(get_name_suffix, set_name_suffix) diff --git a/openslides/participant/templates/participant/overview.html b/openslides/participant/templates/participant/overview.html index 452bdcb53..f950bc302 100644 --- a/openslides/participant/templates/participant/overview.html +++ b/openslides/participant/templates/participant/overview.html @@ -26,11 +26,11 @@ - + + {% for detail in details %} + {% endfor %}