Merge pull request #644 from normanjaeckel/ListOfSpeakersToPersonalInfoWidget
Items now appear also in the personal info widget
This commit is contained in:
commit
97e5815664
@ -1,6 +1,16 @@
|
||||
{% load i18n %}
|
||||
{% load tags %}
|
||||
|
||||
<ul style="line-height: 180%">
|
||||
{% trans 'I am on the list of speakers of the following items:' %}
|
||||
{% for item in items %}
|
||||
<li><a href="{% model_url item %}">{{ item }}</a></li>
|
||||
{% empty %}
|
||||
<li><i>{% trans 'None' %}</i></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<ul style="line-height: 180%">
|
||||
{% trans 'I submitted the following motions:' %}
|
||||
{% for motion in submitted_motions %}
|
||||
|
@ -19,7 +19,7 @@ from openslides.projector.projector import Widget
|
||||
|
||||
def get_widgets(request):
|
||||
"""
|
||||
Returns the widgets of the account app. It is only a personal_info_widget.
|
||||
Returns the widgets of the account app. It is only the personal_info_widget.
|
||||
"""
|
||||
if not isinstance(request.user, AnonymousUser):
|
||||
return [get_personal_info_widget(request)]
|
||||
@ -30,12 +30,21 @@ def get_widgets(request):
|
||||
def get_personal_info_widget(request):
|
||||
"""
|
||||
Provides a widget for personal info. It shows your submitted and supported
|
||||
motions and where you are supporter or candidate. If one of the modules
|
||||
motion or assignment does not exist, it is not loaded. If both don't
|
||||
exist, the widget disapears.
|
||||
motions, where you are on the list of speakers and where you are supporter
|
||||
or candidate. If one of the modules agenda, motion or assignment does
|
||||
not exist, it is not loaded. If all does not exist, the widget disapears.
|
||||
"""
|
||||
personal_info_context = {}
|
||||
|
||||
try:
|
||||
from openslides.agenda.models import Item
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
personal_info_context.update({
|
||||
'items': Item.objects.filter(
|
||||
speaker__person=request.user,
|
||||
speaker__begin_time=None)})
|
||||
try:
|
||||
from openslides.motion.models import Motion
|
||||
except ImportError:
|
||||
@ -58,7 +67,7 @@ def get_personal_info_widget(request):
|
||||
if personal_info_context:
|
||||
return Widget(
|
||||
name='personal_info',
|
||||
display_name=_('My motions and elections'),
|
||||
display_name=_('My items, motions and elections'),
|
||||
template='account/personal_info_widget.html',
|
||||
context=personal_info_context,
|
||||
permission_required=None,
|
||||
|
@ -19,6 +19,17 @@ class PersonalInfoWidget(TestCase):
|
||||
"""
|
||||
Tests the content of the personal info widget.
|
||||
"""
|
||||
def import_agenda(self):
|
||||
"""
|
||||
Helper function to make the module agenda optional.
|
||||
"""
|
||||
try:
|
||||
from openslides import agenda
|
||||
except ImportError:
|
||||
return False
|
||||
else:
|
||||
return agenda
|
||||
|
||||
def import_motion(self):
|
||||
"""
|
||||
Helper function to make the module motion optional.
|
||||
@ -49,7 +60,19 @@ class PersonalInfoWidget(TestCase):
|
||||
|
||||
def test_widget_appearance(self):
|
||||
response = self.client.get('/projector/dashboard/')
|
||||
self.assertContains(response, '<h3>My motions and elections</h3>', status_code=200)
|
||||
self.assertContains(response, '<h3>My items, motions and elections</h3>', status_code=200)
|
||||
|
||||
def test_item_list(self):
|
||||
agenda = self.import_agenda()
|
||||
if agenda:
|
||||
item_1 = agenda.models.Item.objects.create(title='My Item Title iw5ohNgee4eiYahb5Eiv')
|
||||
speaker = agenda.models.Speaker.objects.add(item=item_1, person=self.user)
|
||||
response = self.client.get('/projector/dashboard/')
|
||||
self.assertContains(response, 'I am on the list of speakers of the following items:', status_code=200)
|
||||
self.assertContains(response, 'My Item Title iw5ohNgee4eiYahb5Eiv', status_code=200)
|
||||
speaker.begin_speach()
|
||||
response = self.client.get('/projector/dashboard/')
|
||||
self.assertNotContains(response, 'My Item Title iw5ohNgee4eiYahb5Eiv', status_code=200)
|
||||
|
||||
def test_submitter_list(self):
|
||||
motion = self.import_motion()
|
||||
|
Loading…
Reference in New Issue
Block a user