Merge remote-tracking branch 'norman/Some_Fixes_for_1_3_b1'

Conflicts:
	openslides/__init__.py
	openslides/projector/views.py
This commit is contained in:
Oskar Hahn 2012-10-31 15:27:47 +01:00
commit 424d10cb63
17 changed files with 382 additions and 26 deletions

View File

@ -227,10 +227,12 @@ class Assignment(models.Model, SlideMixin):
"""
return the slide dict
"""
polls = self.poll_set
data = super(Assignment, self).slide()
data['assignment'] = self
data['title'] = self.name
data['polls'] = self.poll_set.filter(published=True)
data['some_polls_available'] = polls.exists()
data['polls'] = polls.filter(published=True)
data['vote_results'] = self.vote_results(only_published=True)
data['assignment_publish_winner_results_only'] = \
config['assignment_publish_winner_results_only']

View File

@ -31,7 +31,12 @@
<tr class="{% cycle '' 'odd' %}
{% if assignment.active %}activeline{% endif %}">
<td><a href="{% url assignment_view assignment.id %}">{{ assignment }}</a></td>
<td>{{ assignment.candidates|length }} / {{ assignment.posts }}</td>
<td>
{{ assignment.posts }} {% trans "posts" %} / {{ assignment.elected|length }} {% trans "elected" %}
{% if assignment.status != 'fin' %}
/ {{ assignment.candidates|length }} {% trans "candidates" %}
{% endif %}
</td>
<td>{{ assignment.get_status_display }}</td>
<td>
<span style="width: 1px; white-space: nowrap;">

View File

@ -88,18 +88,36 @@
{% endif %}
{% endif %}
<h3>{% trans "Elected Candidates" %}</h3>
<ul>
{% for person in assignment.elected %}
<li>
{{ person }}
{% if perms.assignment.can_manage_assignment %}
{% if assignment.status == "sea" or assignment.status == "vot" %}
<a href="{% url assignment_user_not_elected assignment.id person.person_id %}"><img src="{% static 'images/icons/delete.png' %}" title="{% trans 'Remove candidate' %}"></a>
{% endif %}
{% endif %}
</li>
{% empty %}
<li>{% trans "There are no elected candidates available." %}</li>
{% endfor %}
</ul>
{% if perms.assignment.can_manage_assignments %}
<h3>{% trans "Blocked Candidates" %}</h3>
<ul>
{% for candidate in blocked_candidates %}
{% for person in blocked_candidates %}
<li>
{{ candidate }}<a href="{% url assignment_delother assignment.id candidate.person_id %}"><img src="{% static 'images/icons/delete.png' %}" title="{% trans 'Remove candidate' %}"></a>
{{ person }}<a href="{% url assignment_delother assignment.id person.person_id %}"><img src="{% static 'images/icons/delete.png' %}" title="{% trans 'Remove candidate' %}"></a>
</li>
{% empty %}
<li>{% trans "There are no blocked candidates." %}</li>
<li>{% trans "There are no blocked candidates available." %}</li>
{% endfor %}
</ul>
{% endif %}
<h3>{% trans "Election results" %}</h3>
{% if polls.exists %}

View File

@ -122,6 +122,8 @@
</tr>
</table>
{% elif some_polls_available %}
<i>{% trans "Vote results are not published yet." %}</i>
{% elif assignment.candidates %}
<i>{% trans "No ballots available." %}</i>
{% endif %}

View File

@ -542,7 +542,8 @@ class AssignmentPollPDF(PDFView):
ballot_string = _("%d. ballot") % self.poll.get_ballot()
candidate_string = ungettext("%d candidate", "%d candidates",
len(options)) % len(options)
available_posts_string = _("%d available posts") % self.poll.assignment.posts
available_posts_string = ungettext("%d available post", "%d available posts",
self.poll.assignment.posts) % self.poll.assignment.posts
cell.append(Paragraph("%s, %s, %s" % (ballot_string, candidate_string,
available_posts_string), stylesheet['Ballot_description']))
cell.append(Spacer(0, 0.4 * cm))

View File

@ -78,14 +78,17 @@ class User(DjangoUser, PersonMixin, Person):
self.save()
@models.permalink
def get_absolute_url(self, link='edit'):
def get_absolute_url(self, link='view'):
"""
Return the URL to this user.
link can be:
* view
* edit
* delete
"""
if link == 'view':
return ('user_view', [str(self.id)])
if link == 'edit':
return ('user_edit', [str(self.id)])
if link == 'delete':
@ -114,14 +117,17 @@ class Group(DjangoGroup, PersonMixin, Person):
description = models.TextField(blank=True, verbose_name=_("Description"))
@models.permalink
def get_absolute_url(self, link='edit'):
def get_absolute_url(self, link='view'):
"""
Return the URL to this user.
link can be:
* view
* edit
* delete
"""
if link == 'view':
return ('user_group_view', [str(self.id)])
if link == 'edit':
return ('user_group_edit', [str(self.id)])
if link == 'delete':

View File

@ -27,4 +27,51 @@
<li><a href="{% url print_passwords %}"><img src="{% static 'images/icons/pdf.png' %}"> {% trans 'First time passwords as PDF' %}</a></li>
{% endif %}
</ul>
{# second submenu #}
{% if shown_user %}
<br>
<h3>{{ shown_user.clean_name }}</h3>
<ul>
{# view shown_user #}
<li class="{% if request.path == 'foo' %}selected{% endif %}">
<a href="{% model_url shown_user 'view' %}">{% trans 'View participant' %}</a>
</li>
{% if perms.participant.can_manage_participant %}
{# edit shown_user #}
<li class="{% if request.path == 'foo' %}selected{% endif %}">
<a href="{% model_url shown_user 'edit' %}"><img src="{% static 'images/icons/edit.png' %}"> {% trans 'Edit participant' %}</a>
</li>
{# delete shown_user #}
<li>
<a href="{% model_url shown_user 'delete' %}"><img src="{% static 'images/icons/delete.png' %}"> {% trans 'Delete participant' %}</a>
</li>
{% endif %}
</ul>
{% elif group %}
<br>
<h3>{{ group.name }}</h3>
<ul>
{# view group #}
<li class="{% if request.path == 'foo' %}selected{% endif %}">
<a href="{% model_url group 'view' %}">{% trans 'View group' %}</a>
</li>
{# edit group #}
<li class="{% if request.path == 'foo' %}selected{% endif %}">
<a href="{% model_url group 'edit' %}"><img src="{% static 'images/icons/edit.png' %}"> {% trans 'Edit group' %}</a>
</li>
{# delete group #}
{% if group.name != 'Anonymous' %}
<li>
<a href="{% model_url group 'delete' %}"><img src="{% static 'images/icons/delete.png' %}"> {% trans 'Delete group' %}</a>
</li>
{% endif %}
</ul>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,22 @@
{% extends "participant/base_participant.html" %}
{% load i18n %}
{% load tags %}
{% block title %}{{ block.super }} {{ group }}{% endblock %}
{% block content %}
<h1>{{ group }}</h1>
<p>{{ group.description }}</p>
<h2>{% trans "Members" %}</h2>
{% for member in group.user_set.all %}
<p>{{ member }}</p>
{% empty %}
<p>{% trans "This group has not any members." %}</p>
{% endfor %}
{% endblock %}

View File

@ -2,6 +2,7 @@
{% load i18n %}
{% load staticfiles %}
{% load tags %}
{% block title %}{{ block.super }} {% trans "User groups" %}{% endblock %}
@ -14,7 +15,7 @@
</tr>
{% for group in groups %}
<tr class="{% cycle '' 'odd' %}">
<td>{{ group.name }}</td>
<td><a href="{% model_url group 'view' %}">{{ group.name }}</a></td>
<td><a href="{% url user_group_edit group.id %}"><img src="{% static 'images/icons/edit.png' %}" title="{% trans 'Edit group' %}"></a>
{% if group.name != 'Anonymous' %}
<a href="{% url user_group_delete group.id %}"><img src="{% static 'images/icons/delete.png' %}" title="{% trans 'Delete group' %}"></a>

View File

@ -0,0 +1,26 @@
{% load i18n %}
{% load tags %}
<ul style="line-height: 180%">
{% for group in groups %}
{% if group.name != 'Anonymous' %}
<li class="{% if group.active %}activeline{% endif %}">
<a href="{% url projector_activate_slide group.sid %}" class="activate_link {% if group.active %}active{% endif %}">
<div></div>
</a>
<a href="{% model_url group 'delete' %}" title="{% trans 'Delete' %}" class="icon delete right">
<span></span>
</a>
<a href="{% model_url group 'edit' %}" title="{% trans 'Edit' %}" class="icon edit right">
<span></span>
</a>
<a href="{% url projctor_preview_slide group.sid %}" title="{% trans 'Preview' %}" class="icon preview right">
<span></span>
</a>
<a href="{% model_url group 'view' %}">{{ group }}</a>
</li>
{% endif %}
{% empty %}
<li>{% trans 'No groups available.' %}</li>
{% endfor %}
</ul>

View File

@ -76,7 +76,7 @@
</tr>
{% for user in users %}
<tr class="{% cycle '' 'odd' %}">
<td>{{ user.first_name }}</td>
<td><a href="{% model_url user 'view' %}">{{ user.first_name }}</a></td>
<td>{{ user.last_name }}</td>
<td>{{ user.detail }}</td>
<td>{{ user.get_type_display }}</td>

View File

@ -0,0 +1,49 @@
{% load i18n %}
{% load tags %}
<ul style="line-height: 180%">
{% trans "You submitted the following motions:" %}
{% for motion in submitted_motions %}
<li>
<a href="{% model_url motion 'view' %}">{{ motion.public_version.title }}</a>
({% trans "motion" %}
{% if motion.number %}
{{ motion.number }})
{% else %}
<i>[{% trans "no number" %}]</i>)
{% endif %}
</li>
{% empty %}
<li>{% trans "Currently none" %}</li>
{% endfor %}
</ul>
{% if config_motion_min_supporters %}
<hr />
<ul>
{% trans "You support the following motions:" %}
{% for motion in supported_motions %}
<li>
<a href="{% model_url motion 'view' %}">{{ motion.public_version.title }}</a>
({% trans "motion" %}
{% if motion.number %}
{{ motion.number }})
{% else %}
<i>[{% trans "no number" %}]</i>)
{% endif %}
</li>
{% empty %}
<li>{% trans "Currently none" %}</li>
{% endfor %}
</ul>
{% endif %}
<hr />
<ul style="line-height: 180%">
{% trans "You are candidate in the following assignments:" %}
{% for assignment in assignments %}
<li><a href="{% model_url assignment 'view' %}">{{ assignment }}</a></li>
{% empty %}
<li>{% trans "Currently none" %}</li>
{% endfor %}
</ul>

View File

@ -0,0 +1,52 @@
{% extends "participant/base_participant.html" %}
{% load i18n %}
{% load tags %}
{% block title %}{{ block.super }} {{ shown_user }}{% endblock %}
{% block content %}
<h1>{{ shown_user }}</h1>
<p>{{ shown_user.email }}</p>
<h2>{% trans "Groups" %}</h2>
<p>
{% for group in shown_user.groups.all %}
{{ group }},
{% empty %}
{% trans "The participant is not member of any group." %}
{% endfor %}
</p>
{% if shown_user.get_gender_display %}
<h2>{% trans "Gender" %}</h2>
<p>{{ shown_user.get_gender_display }}</p>
{% endif %}
{% if shown_user.get_type_display %}
<h2>{% trans "Type" %}</h2>
<p>{{ shown_user.get_type_display }}</p>
{% endif %}
{% if shown_user.committee %}
<h2>{% trans "Committee" %}</h2>
<p>{{ shown_user.committee }}</p>
{% endif %}
{% if perms.participant.can_manage_participant %}
{% if shown_user.comment %}
<h2>{% trans "Comment" %}</h2>
<p>{{ shown_user.comment }}</p>
{% endif %}
<h2>{% trans "Last Login" %}</h2>
{% if shown_user.last_login > shown_user.date_joined %}
<p>{{ shown_user.last_login }}</p>
{% else %}
<p>{% trans "The participant was not logged in yet." %}</p>
{% endif %}
{% endif %}
{% endblock %}

View File

@ -0,0 +1,24 @@
{% load i18n %}
{% load tags %}
<ul style="line-height: 180%">
{% for user in users %}
<li class="{% if user.active %}activeline{% endif %}">
<a href="{% url projector_activate_slide user.sid %}" class="activate_link {% if user.active %}active{% endif %}">
<div></div>
</a>
<a href="{% model_url user 'delete' %}" title="{% trans 'Delete' %}" class="icon delete right">
<span></span>
</a>
<a href="{% model_url user 'edit' %}" title="{% trans 'Edit' %}" class="icon edit right">
<span></span>
</a>
<a href="{% url projctor_preview_slide user.sid %}" title="{% trans 'Preview' %}" class="icon preview right">
<span></span>
</a>
<a href="{% model_url user 'view' %}">{{ user }}</a>
</li>
{% empty %}
<li>{% trans 'No users available.' %}</li>
{% endfor %}
</ul>

View File

@ -14,14 +14,16 @@ from django.conf.urls.defaults import url, patterns
from django.core.urlresolvers import reverse
from openslides.participant.views import (
ParticipantsListPDF, ParticipantsPasswordsPDF, Overview, UserCreateView,
UserUpdateView, UserDeleteView, SetUserStatusView, UserImportView,
ResetPasswordView, GroupOverviewView, GroupCreateView, GroupUpdateView,
GroupDeleteView)
UserOverview, UserCreateView, UserDetailView, UserUpdateView,
UserDeleteView, ResetPasswordView, SetUserStatusView, UserImportView,
GroupOverview, GroupCreateView, GroupDetailView, GroupUpdateView, GroupDeleteView,
ParticipantsListPDF, ParticipantsPasswordsPDF)
urlpatterns = patterns('openslides.participant.views',
urlpatterns = patterns('',
# User
url(r'^$',
Overview.as_view(),
UserOverview.as_view(),
name='user_overview',
),
@ -30,6 +32,11 @@ urlpatterns = patterns('openslides.participant.views',
name='user_new',
),
url(r'^(?P<pk>\d+)/$',
UserDetailView.as_view(),
name='user_view',
),
url(r'^(?P<pk>\d+)/edit/$',
UserUpdateView.as_view(),
name='user_edit',
@ -45,12 +52,6 @@ urlpatterns = patterns('openslides.participant.views',
name='user_reset_password',
),
url(r'^(?P<pk>\d+)/status/toggle/$',
SetUserStatusView.as_view(),
{'action': 'toggle'},
name='user_status_toggle',
),
url(r'^(?P<pk>\d+)/status/activate/$',
SetUserStatusView.as_view(),
{'action': 'activate'},
@ -63,13 +64,20 @@ urlpatterns = patterns('openslides.participant.views',
name='user_status_deactivate',
),
url(r'^(?P<pk>\d+)/status/toggle/$',
SetUserStatusView.as_view(),
{'action': 'toggle'},
name='user_status_toggle',
),
url(r'^import/$',
UserImportView.as_view(),
name='user_import',
),
# Group
url(r'^group/$',
GroupOverviewView.as_view(),
GroupOverview.as_view(),
name='user_group_overview',
),
@ -78,6 +86,11 @@ urlpatterns = patterns('openslides.participant.views',
name='user_group_new',
),
url(r'^group/(?P<pk>\d+)/$',
GroupDetailView.as_view(),
name='user_group_view',
),
url(r'^group/(?P<pk>\d+)/edit/$',
GroupUpdateView.as_view(),
name='user_group_edit',
@ -88,6 +101,7 @@ urlpatterns = patterns('openslides.participant.views',
name='user_group_delete',
),
# PDF
url(r'^print/$',
ParticipantsListPDF.as_view(),
name='user_print',

View File

@ -44,6 +44,11 @@ from openslides.utils.views import (
from openslides.config.models import config
from openslides.projector.projector import Widget
from openslides.motion.models import Motion
from openslides.assignment.models import Assignment
from openslides.participant.api import gen_username, gen_password, import_users
from openslides.participant.forms import (
UserCreateForm, UserUpdateForm, UsersettingsForm,
@ -51,7 +56,7 @@ from openslides.participant.forms import (
from openslides.participant.models import User, Group
class Overview(ListView):
class UserOverview(ListView):
"""
Show all participants (users).
"""
@ -109,7 +114,7 @@ class Overview(ListView):
return query.all()
def get_context_data(self, **kwargs):
context = super(Overview, self).get_context_data(**kwargs)
context = super(UserOverview, self).get_context_data(**kwargs)
all_users = User.objects.count()
@ -137,6 +142,27 @@ class Overview(ListView):
return context
from openslides.utils.views import DetailView, PermissionMixin
class UserDetailView(DetailView, PermissionMixin):
"""
Classed based view to show a specific user in the interface.
"""
permission_required = 'participant.can_see_participant'
model = User
template_name = 'participant/user_detail.html'
context_object_name = 'shown_user'
class GroupDetailView(DetailView, PermissionMixin):
"""
Classed based view to show a specific group in the interface.
"""
permission_required = 'participant.can_manage_participant'
model = Group
template_name = 'participant/group_detail.html'
context_object_name = 'group'
class UserCreateView(CreateView):
"""
Create a new participant.
@ -352,7 +378,7 @@ class ResetPasswordView(SingleObjectMixin, QuestionMixin, RedirectView):
return _('The Password for %s was successfully reset.') % html_strong(self.object)
class GroupOverviewView(ListView):
class GroupOverview(ListView):
"""
Overview over all groups.
"""
@ -506,3 +532,63 @@ def register_tab(request):
permission=request.user.has_perm('participant.can_see_participant') or
request.user.has_perm('participant.can_manage_participant'),
selected=selected)
def get_widgets(request):
"""
Returns all widgets of the participant app. This is a user_widget, a
group_widget and a personal_info_widget.
"""
return [
get_personal_info_widget(request),
get_user_widget(request),
get_group_widget(request)]
def get_personal_info_widget(request):
"""
Provides a widget for personal info. It shows your submitted motions
and where you are supporter or candidate.
"""
personal_info_context = {
'submitted_motions': Motion.objects.filter(submitter=request.user),
'config_motion_min_supporters': config['motion_min_supporters'],
'supported_motions': Motion.objects.filter(motionsupporter=request.user),
'assignments': Assignment.objects.filter(
assignmentcandidate__person=request.user,
assignmentcandidate__blocked=False),}
return Widget(
name='personal_info',
display_name=_('On You'),
template='participant/personal_info_widget.html',
context=personal_info_context,
permission_required=None,
default_column=1)
def get_user_widget(request):
"""
Provides a widget with all users. This is for short activation of
user slides.
"""
return Widget(
name='user',
display_name=_('Users'),
template='participant/user_widget.html',
context={'users': User.objects.all(),},
permission_required='projector.can_manage_projector',
default_column=1)
def get_group_widget(request):
"""
Provides a widget with all groups. This is for short activation of
group slides.
"""
return Widget(
name='group',
display_name=_('Groups'),
template='participant/group_widget.html',
context={'groups': Group.objects.all(),},
permission_required='projector.can_manage_projector',
default_column=1)

View File

@ -0,0 +1 @@
{{ welcometext|safe|linebreaks }}