Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit d2e1f27

Browse files
committed
added workshop widget
1 parent aba63d6 commit d2e1f27

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

dashboard/dashboard_widgets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
from ophasebase.dashboard_components import CountdownWidget
33
from staff.dashboard_widgets import StaffCountWidget
44
from students.dashboard_widgets import StudentCountWidget
5+
from workshops.dashboard_widgets import WorkshopCountWidget
56

67

78
class DashboardWidgets():
89
active_widgets = [
910
CountdownWidget(),
1011
StaffCountWidget(),
1112
StudentCountWidget(),
13+
WorkshopCountWidget(),
1214
ExamWidget()
1315
]

workshops/dashboard_widgets.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django.utils.translation import ugettext_lazy as _
2+
3+
from dashboard.components import TemplateWidgetComponent
4+
from ophasebase.models import Ophase
5+
from workshops.models import Workshop
6+
7+
class WorkshopCountWidget(TemplateWidgetComponent):
8+
name = _('Workshops')
9+
template_name = "workshops/dashboard/widget_workshops.html"
10+
status = 'info'
11+
12+
def get_context_data(self):
13+
context = super().get_context_data()
14+
current_ophase = Ophase.current()
15+
if current_ophase is not None:
16+
workshops = Workshop.get_current()
17+
context['num_workshops'] = workshops.count()
18+
context['filled_slots'] = sum(w.how_often for w in workshops)
19+
context['num_workshop_tutors'] = len(set(w.tutor_mail for w in workshops))
20+
return context

workshops/locale/en/LC_MESSAGES/django.po

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2016-07-11 14:12+0200\n"
11-
"PO-Revision-Date: 2016-07-11 14:13+0200\n"
10+
"POT-Creation-Date: 2016-07-11 15:06+0200\n"
11+
"PO-Revision-Date: 2016-07-11 15:06+0200\n"
1212
"Last-Translator: \n"
1313
"Language-Team: \n"
1414
"Language: en\n"
@@ -17,6 +17,11 @@ msgstr ""
1717
"Content-Transfer-Encoding: 8bit\n"
1818
"X-Generator: Poedit 1.8.8\n"
1919

20+
#: dashboard_widgets.py:8 models.py:32
21+
#: templates/workshops/dashboard/widget_workshops.html:3
22+
msgid "Workshops"
23+
msgstr "Workshops"
24+
2025
#: models.py:11
2126
msgid "Workshopslot"
2227
msgstr "Workshop slot"
@@ -41,10 +46,6 @@ msgstr "End"
4146
msgid "Workshop"
4247
msgstr "Workshop"
4348

44-
#: models.py:32
45-
msgid "Workshops"
46-
msgstr "Workshops"
47-
4849
#: models.py:35
4950
msgid "Name"
5051
msgstr "Name"
@@ -208,6 +209,14 @@ msgstr ""
208209
"An email was sent to the submitted address. If you do not receive the email "
209210
"or when there are changes regarding your workshop, please write an email to"
210211

212+
#: templates/workshops/dashboard/widget_workshops.html:4
213+
msgid "Gefüllte Slots"
214+
msgstr "Filled slots"
215+
216+
#: templates/workshops/dashboard/widget_workshops.html:5
217+
msgid "Workshoptutoren"
218+
msgstr "Workshop tutors"
219+
211220
#: templates/workshops/workshop_form.html:14
212221
msgid "Zurücksetzen"
213222
msgstr "Reset"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% load i18n %}<table class="table" id="workshops_table">
2+
<tbody>
3+
<tr><td>{% trans "Workshops" %}:</td><td>{{ num_workshops }}</td></tr>
4+
<tr><td>{% trans "Gefüllte Slots" %}:</td><td>{{ filled_slots }}</td></tr>
5+
<tr><td>{% trans "Workshoptutoren" %}:</td><td>{{ num_workshop_tutors }}</td></tr>
6+
</tbody>
7+
</table>

0 commit comments

Comments
 (0)