Merge remote-tracking branch 'emanuel/master'
This commit is contained in:
commit
3aefd252ff
@ -164,7 +164,10 @@ class Application(models.Model, SlideMixin):
|
||||
yield object.person
|
||||
|
||||
def is_supporter(self, person):
|
||||
try:
|
||||
return self.applicationsupporter_set.filter(person=person).exists()
|
||||
except AttributeError:
|
||||
return False
|
||||
|
||||
@property
|
||||
def enough_supporters(self):
|
||||
@ -534,6 +537,7 @@ class Application(models.Model, SlideMixin):
|
||||
('can_support_application', ugettext_noop("Can support motions")),
|
||||
('can_manage_application', ugettext_noop("Can manage motions")),
|
||||
)
|
||||
ordering = ('number',)
|
||||
|
||||
|
||||
class AVersion(models.Model):
|
||||
|
@ -49,7 +49,7 @@
|
||||
<td>{% if application.number %}{{ application.number }}{% else %}-{% endif %}</td>
|
||||
<td><a href="{% url application_view application.id %}">{{ application.public_version.title }}</a></td>
|
||||
{% if min_supporters > 0 %}
|
||||
<td>{{ application.supporter.count }}</td>
|
||||
<td>{{ application.count_supporters }}</td>
|
||||
{% endif %}
|
||||
<td>{% if application.status != "pub" %}
|
||||
{{ application.get_status_display }}<br>
|
||||
|
@ -102,8 +102,6 @@ def overview(request):
|
||||
if sort.startswith('aversion_'):
|
||||
# limit result to last version of an application
|
||||
query = query.filter(aversion__id__in=[x.last_version.id for x in Application.objects.all()])
|
||||
else:
|
||||
query = query.order_by('number')
|
||||
|
||||
if 'reverse' in sortfilter:
|
||||
query = query.reverse()
|
||||
@ -468,7 +466,7 @@ class ApplicationDelete(DeleteView):
|
||||
elif self.object:
|
||||
if not 'delete' in self.object.get_allowed_actions(user=request.user):
|
||||
messages.error(request, _("You can not delete motion <b>%s</b>.") % self.object)
|
||||
else:
|
||||
elif self.get_answer() == 'yes':
|
||||
title = self.object.title
|
||||
self.object.delete(force=True)
|
||||
messages.success(request, _("Motion <b>%s</b> was successfully deleted.") % title)
|
||||
@ -681,7 +679,7 @@ class ApplicationPDF(PDFView):
|
||||
if preamble:
|
||||
story.append(Paragraph("%s" % preamble.replace('\r\n','<br/>'), stylesheet['Paragraph']))
|
||||
story.append(Spacer(0,0.75*cm))
|
||||
applications = Application.objects.order_by('number')
|
||||
applications = Application.objects.all()
|
||||
if not applications: # No applications existing
|
||||
story.append(Paragraph(_("No motions available."), stylesheet['Heading3']))
|
||||
else: # Print all Applications
|
||||
@ -835,9 +833,9 @@ class ApplicationPollPDF(PDFView):
|
||||
|
||||
# set number of ballot papers
|
||||
if ballot_papers_selection == "NUMBER_OF_DELEGATES":
|
||||
number = User.objects.filter(profile__type__iexact="delegate").count()
|
||||
number = User.objects.filter(type__iexact="delegate").count()
|
||||
elif ballot_papers_selection == "NUMBER_OF_ALL_PARTICIPANTS":
|
||||
number = int(Profile.objects.count())
|
||||
number = int(User.objects.count())
|
||||
else: # ballot_papers_selection == "CUSTOM_NUMBER"
|
||||
number = int(ballot_papers_number)
|
||||
number = max(1, number)
|
||||
@ -899,5 +897,5 @@ def get_widgets(request):
|
||||
Widget(
|
||||
name='applications',
|
||||
template='application/widget.html',
|
||||
context={'applications': Application.objects.all().order_by('number')},
|
||||
context={'applications': Application.objects.all()},
|
||||
permission_required='application.can_manage_application')]
|
||||
|
@ -122,8 +122,11 @@ class Assignment(models.Model, SlideMixin):
|
||||
"""
|
||||
return True, if person is a candidate.
|
||||
"""
|
||||
try:
|
||||
return self.assignment_candidats.filter(person=person) \
|
||||
.exclude(blocked=True).exists()
|
||||
except AttributeError:
|
||||
return False
|
||||
|
||||
def is_blocked(self, person):
|
||||
"""
|
||||
@ -253,6 +256,7 @@ class Assignment(models.Model, SlideMixin):
|
||||
('can_nominate_self', ugettext_noop("Can nominate themselves")),
|
||||
('can_manage_assignment', ugettext_noop("Can manage assignment")),
|
||||
)
|
||||
ordering = ('name',)
|
||||
|
||||
register_slidemodel(Assignment)
|
||||
|
||||
|
@ -63,8 +63,8 @@
|
||||
|
||||
{% for candidate, poll_list in vote_results.items %}
|
||||
<tr class="{% cycle 'odd' '' %}">
|
||||
<td class="candidate{% if candidate in assignment.elected.all %} elected{% endif %}">
|
||||
{% if candidate in assignment.elected.all %}
|
||||
<td class="candidate{% if candidate in assignment.elected %} elected{% endif %}">
|
||||
{% if candidate in assignment.elected %}
|
||||
<a class="elected">
|
||||
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Candidate is elected' %}">
|
||||
</a>
|
||||
@ -72,8 +72,8 @@
|
||||
{{ candidate }}
|
||||
</td>
|
||||
{% for vote in poll_list %}
|
||||
<td style="white-space:nowrap;"{% if candidate in assignment.elected.all %} class="elected"{% endif %}>
|
||||
{% if not assignment_publish_winner_results_only or candidate in assignment.elected.all %}
|
||||
<td style="white-space:nowrap;"{% if candidate in assignment.elected %} class="elected"{% endif %}>
|
||||
{% if not assignment_publish_winner_results_only or candidate in assignment.elected %}
|
||||
{% if 'Yes' in vote and 'No' in vote and 'Abstain' in vote %}
|
||||
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ vote.Yes }}<br>
|
||||
<img src="{% static 'images/icons/voting-no.png' %}" title="{% trans 'No' %}"> {{ vote.No }}<br>
|
||||
|
@ -59,7 +59,7 @@ def get_overview(request):
|
||||
if sort in ['name','status']:
|
||||
query = query.order_by(sort)
|
||||
except KeyError:
|
||||
query = query.order_by('name')
|
||||
pass
|
||||
if 'reverse' in request.GET:
|
||||
query = query.reverse()
|
||||
|
||||
@ -353,7 +353,7 @@ class AssignmentPDF(PDFView):
|
||||
story.append(Paragraph("%s" % preamble.replace('\r\n', '<br/>'),
|
||||
stylesheet['Paragraph']))
|
||||
story.append(Spacer(0, 0.75 * cm))
|
||||
assignments = Assignment.objects.order_by('name')
|
||||
assignments = Assignment.objects.all()
|
||||
if not assignments: # No assignments existing
|
||||
story.append(Paragraph(_("No assignments available."),
|
||||
stylesheet['Heading3']))
|
||||
@ -554,9 +554,9 @@ class AssignmentPollPDF(PDFView):
|
||||
|
||||
# set number of ballot papers
|
||||
if ballot_papers_selection == "NUMBER_OF_DELEGATES":
|
||||
number = User.objects.filter(profile__type__iexact="delegate").count()
|
||||
number = User.objects.filter(type__iexact="delegate").count()
|
||||
elif ballot_papers_selection == "NUMBER_OF_ALL_PARTICIPANTS":
|
||||
number = int(Profile.objects.count())
|
||||
number = int(User.objects.count())
|
||||
else: # ballot_papers_selection == "CUSTOM_NUMBER"
|
||||
number = int(ballot_papers_number)
|
||||
number = max(1, number)
|
||||
@ -567,8 +567,8 @@ class AssignmentPollPDF(PDFView):
|
||||
candidate = option.candidate
|
||||
cell.append(Paragraph(candidate.user.get_full_name(),
|
||||
stylesheet['Ballot_option_name']))
|
||||
if candidate.name_surfix:
|
||||
cell.append(Paragraph("(%s)" % candidate.name_surfix,
|
||||
if candidate.name_suffix:
|
||||
cell.append(Paragraph("(%s)" % candidate.name_suffix,
|
||||
stylesheet['Ballot_option_group']))
|
||||
else:
|
||||
cell.append(Paragraph(" ",
|
||||
@ -675,5 +675,5 @@ def get_widgets(request):
|
||||
Widget(
|
||||
name=_('Assignments'),
|
||||
template='assignment/widget.html',
|
||||
context={'assignments': Assignment.objects.all().order_by('name')},
|
||||
context={'assignments': Assignment.objects.all()},
|
||||
permission_required='assignment.can_manage_assignment')]
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -113,3 +113,6 @@ class ConfigForm(forms.Form, CssClassMixin):
|
||||
required=False,
|
||||
label=_("Welcome text"),
|
||||
help_text=_("Printed in PDF of first time passwords only."))
|
||||
participant_sort_users_by_first_name = forms.BooleanField(
|
||||
required=False,
|
||||
label=_("Sort users by first name"))
|
||||
|
@ -19,6 +19,7 @@ from django.utils.translation import ugettext_lazy as _, ugettext_noop
|
||||
from openslides.utils.person import PersonMixin
|
||||
from openslides.utils.person.signals import receive_persons
|
||||
|
||||
from openslides.config.models import config
|
||||
from openslides.config.signals import default_config_value
|
||||
|
||||
|
||||
@ -28,7 +29,7 @@ class User(DjangoUser, PersonMixin):
|
||||
('male', _('Male')),
|
||||
('female', _('Female')),
|
||||
)
|
||||
TYPE_CHOICE = (
|
||||
TYPE_CHOICES = (
|
||||
('delegate', _('Delegate')),
|
||||
('observer', _('Observer')),
|
||||
('staff', _('Staff')),
|
||||
@ -43,7 +44,7 @@ class User(DjangoUser, PersonMixin):
|
||||
max_length=50, choices=GENDER_CHOICES, blank=True,
|
||||
verbose_name=_("Gender"), help_text=_('Only for filter the userlist.'))
|
||||
type = models.CharField(
|
||||
max_length=100, choices=TYPE_CHOICE, blank=True,
|
||||
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"),
|
||||
@ -99,6 +100,7 @@ class User(DjangoUser, PersonMixin):
|
||||
('can_manage_participant',
|
||||
ugettext_noop("Can manage participant")),
|
||||
)
|
||||
ordering = ('last_name',)
|
||||
|
||||
|
||||
class Group(DjangoGroup, PersonMixin):
|
||||
@ -125,11 +127,21 @@ class Group(DjangoGroup, PersonMixin):
|
||||
def __unicode__(self):
|
||||
return unicode(self.name)
|
||||
|
||||
class Meta:
|
||||
ordering = ('name',)
|
||||
|
||||
class UsersConnector(object):
|
||||
|
||||
class UsersAndGroupsToPersons(object):
|
||||
"""
|
||||
Object to send all Users and Groups or a special User or Group to
|
||||
the Person-API via receice_persons()
|
||||
"""
|
||||
def __init__(self, person_prefix_filter=None, id_filter=None):
|
||||
self.person_prefix_filter = person_prefix_filter
|
||||
self.id_filter = id_filter
|
||||
if config['participant_sort_users_by_first_name']:
|
||||
self.users = User.objects.all().order_by('first_name')
|
||||
else:
|
||||
self.users = User.objects.all()
|
||||
self.groups = Group.objects.filter(group_as_person=True)
|
||||
|
||||
@ -159,7 +171,10 @@ class UsersConnector(object):
|
||||
|
||||
@receiver(receive_persons, dispatch_uid="participant")
|
||||
def receive_persons(sender, **kwargs):
|
||||
return UsersConnector(person_prefix_filter=kwargs['person_prefix_filter'],
|
||||
"""
|
||||
Answers to the Person-API
|
||||
"""
|
||||
return UsersAndGroupsToPersons(person_prefix_filter=kwargs['person_prefix_filter'],
|
||||
id_filter=kwargs['id_filter'])
|
||||
|
||||
|
||||
@ -172,6 +187,7 @@ def default_config(sender, key, **kwargs):
|
||||
return {
|
||||
'participant_pdf_system_url': 'http://example.com:8000',
|
||||
'participant_pdf_welcometext': _('Welcome to OpenSlides!'),
|
||||
'participant_sort_users_by_first_name': False,
|
||||
}.get(key)
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ from openslides.participant.models import User, Group
|
||||
|
||||
class Overview(ListView):
|
||||
"""
|
||||
Show all participants.
|
||||
Show all participants (users).
|
||||
"""
|
||||
permission_required = 'participant.can_see_participant'
|
||||
template_name = 'participant/overview.html'
|
||||
@ -96,7 +96,8 @@ class Overview(ListView):
|
||||
query = query.order_by(
|
||||
'%s' % sortfilter['sort'][0])
|
||||
else:
|
||||
query = query.order_by('last_name')
|
||||
if config['participant_sort_users_by_first_name']:
|
||||
query = query.order_by('first_name')
|
||||
|
||||
if 'reverse' in sortfilter:
|
||||
query = query.reverse()
|
||||
@ -412,13 +413,16 @@ class Config(FormView):
|
||||
def get_initial(self):
|
||||
return {
|
||||
'participant_pdf_system_url': config['participant_pdf_system_url'],
|
||||
'participant_pdf_welcometext': config['participant_pdf_welcometext']}
|
||||
'participant_pdf_welcometext': config['participant_pdf_welcometext'],
|
||||
'participant_sort_users_by_first_name': config['participant_sort_users_by_first_name']}
|
||||
|
||||
def form_valid(self, form):
|
||||
config['participant_pdf_system_url'] = (
|
||||
form.cleaned_data['participant_pdf_system_url'])
|
||||
config['participant_pdf_welcometext'] = (
|
||||
form.cleaned_data['participant_pdf_welcometext'])
|
||||
config['participant_sort_users_by_first_name'] = (
|
||||
form.cleaned_data['participant_sort_users_by_first_name'])
|
||||
messages.success(
|
||||
self.request,
|
||||
_('Participants settings successfully saved.'))
|
||||
|
Loading…
Reference in New Issue
Block a user