Merge branch 'develop' into 'master'

Merge sorting fix

Closes #105

See merge request vtmk/web2.0!114
This commit is contained in:
Aarni Halinen
2018-03-26 18:09:27 +03:00
9 changed files with 77 additions and 45 deletions
+1
View File
@@ -19,3 +19,4 @@ mydatabase
settings.json
.vscode/
.DS_Store
*.code-workspace
Binary file not shown.
+22 -16
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-01 22:11+0200\n"
"POT-Creation-Date: 2018-03-02 02:43+0200\n"
"PO-Revision-Date: 2017-11-02 23:09+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -293,11 +293,13 @@ msgstr ""
msgid "Roles"
msgstr ""
#: kaehmy/templates/error.html:8 templates/error.html:8
#: kaehmy/templates/error.html:8 members/templates/error.html:8
#: templates/error.html:8
msgid "Error"
msgstr "Error"
#: kaehmy/templates/error.html:15 templates/error.html:15
#: kaehmy/templates/error.html:15 members/templates/error.html:15
#: templates/error.html:15
msgid "Back"
msgstr "Back"
@@ -434,7 +436,7 @@ msgstr "New application"
msgid "Statistics"
msgstr ""
#: members/forms.py:107 members/models.py:103 members/tables.py:32
#: members/forms.py:107 members/models.py:103 members/tables.py:46
msgid "Member"
msgstr "Member"
@@ -496,14 +498,18 @@ msgstr "Created"
msgid "Members"
msgstr "Members"
#: members/tables.py:13
#: members/tables.py:14
msgid "Last paid"
msgstr "Last paid"
#: members/tables.py:18 members/tables.py:37 members/tables.py:54
#: members/tables.py:19 members/tables.py:51 members/tables.py:68
msgid "Edit"
msgstr "Edit"
#: members/tables.py:33
msgid " (not paid)"
msgstr " (not paid)"
#: members/templates/application_delete_confirm.html:9
msgid "Are you sure you want to delete this application?"
msgstr "Are you sure you want to delete this application?"
@@ -862,12 +868,12 @@ msgstr "has challenged you to a beer drinking contest"
msgid "-sarjassa"
msgstr "series"
#: ohlhafv/templates/email.html:6
#: ohlhafv/templates/email.html:8
msgid "Muistattehan vahvistaa haasteen paikan päällä Smökissä torstaina 15.2"
msgstr ""
"Remeber to confirm the challenge at Smökki on Thursday 15.2. at the event"
#: ohlhafv/templates/email.html:8
#: ohlhafv/templates/email.html:10
msgid "Käy kurkkaamassa muutkin haasteet osoitteessa"
msgstr "Also go and check other challenges at"
@@ -1024,12 +1030,12 @@ msgid "Corporate affairs"
msgstr ""
#: webapp/models.py:95 webapp/templates/freshmen.html:10
#: webapp/templates/navigation.html:9
#: webapp/templates/navigation.html:8
msgid "Freshmen"
msgstr "Freshmen"
#: webapp/models.py:96 webapp/templates/international.html:10
#: webapp/templates/navigation.html:15
#: webapp/templates/navigation.html:14
msgid "International"
msgstr "International"
@@ -1109,11 +1115,11 @@ msgstr ""
msgid "Officials"
msgstr ""
#: webapp/templates/contact.html:10 webapp/templates/navigation.html:21
#: webapp/templates/contact.html:10 webapp/templates/navigation.html:20
msgid "Contact"
msgstr "Contact"
#: webapp/templates/event_calendar.html:10 webapp/templates/navigation.html:12
#: webapp/templates/event_calendar.html:10 webapp/templates/navigation.html:11
msgid "Event calendar"
msgstr "Event calendar"
@@ -1137,19 +1143,19 @@ msgstr "Infoscreen Admin Pane"
msgid "Kaehmy application"
msgstr "Kaehmy application"
#: webapp/templates/jobs.html:10 webapp/templates/navigation.html:28
#: webapp/templates/jobs.html:10 webapp/templates/navigation.html:27
msgid "Jobs"
msgstr "Jobs"
#: webapp/templates/navigation.html:6
#: webapp/templates/navigation.html:5
msgid "Guild"
msgstr "Guild"
#: webapp/templates/navigation.html:18 webapp/templates/sosso.html:10
#: webapp/templates/navigation.html:17 webapp/templates/sosso.html:10
msgid "Sössö"
msgstr "Sössö"
#: webapp/templates/navigation.html:25
#: webapp/templates/navigation.html:24
msgid "Corporate"
msgstr "Corporate"
Binary file not shown.
+22 -16
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-01 22:11+0200\n"
"POT-Creation-Date: 2018-03-02 02:43+0200\n"
"PO-Revision-Date: 2017-11-02 23:04+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -298,11 +298,13 @@ msgstr "Telegram-kanavat"
msgid "Roles"
msgstr "Roolit"
#: kaehmy/templates/error.html:8 templates/error.html:8
#: kaehmy/templates/error.html:8 members/templates/error.html:8
#: templates/error.html:8
msgid "Error"
msgstr "Virhe"
#: kaehmy/templates/error.html:15 templates/error.html:15
#: kaehmy/templates/error.html:15 members/templates/error.html:15
#: templates/error.html:15
msgid "Back"
msgstr "Takaisin"
@@ -442,7 +444,7 @@ msgstr "Uusi kaehmy"
msgid "Statistics"
msgstr "Kaehmytilastot"
#: members/forms.py:107 members/models.py:103 members/tables.py:32
#: members/forms.py:107 members/models.py:103 members/tables.py:46
msgid "Member"
msgstr "Jäsen"
@@ -504,14 +506,18 @@ msgstr "Lisätty"
msgid "Members"
msgstr "Jäsenet"
#: members/tables.py:13
#: members/tables.py:14
msgid "Last paid"
msgstr "Viimeksi maksettu"
#: members/tables.py:18 members/tables.py:37 members/tables.py:54
#: members/tables.py:19 members/tables.py:51 members/tables.py:68
msgid "Edit"
msgstr "Muokkaa"
#: members/tables.py:33
msgid " (not paid)"
msgstr " (ei maksua)"
#: members/templates/application_delete_confirm.html:9
msgid "Are you sure you want to delete this application?"
msgstr "Oletko varma, että haluat poistaa tämän hakemuksen?"
@@ -867,11 +873,11 @@ msgstr ""
msgid "-sarjassa"
msgstr ""
#: ohlhafv/templates/email.html:6
#: ohlhafv/templates/email.html:8
msgid "Muistattehan vahvistaa haasteen paikan päällä Smökissä torstaina 15.2"
msgstr ""
#: ohlhafv/templates/email.html:8
#: ohlhafv/templates/email.html:10
msgid "Käy kurkkaamassa muutkin haasteet osoitteessa"
msgstr ""
@@ -1027,12 +1033,12 @@ msgid "Corporate affairs"
msgstr "Yrityssuhteet"
#: webapp/models.py:95 webapp/templates/freshmen.html:10
#: webapp/templates/navigation.html:9
#: webapp/templates/navigation.html:8
msgid "Freshmen"
msgstr "Fuksit"
#: webapp/models.py:96 webapp/templates/international.html:10
#: webapp/templates/navigation.html:15
#: webapp/templates/navigation.html:14
msgid "International"
msgstr "International"
@@ -1112,11 +1118,11 @@ msgstr "Toimihenkilö"
msgid "Officials"
msgstr "Toimihenkilöt"
#: webapp/templates/contact.html:10 webapp/templates/navigation.html:21
#: webapp/templates/contact.html:10 webapp/templates/navigation.html:20
msgid "Contact"
msgstr "Yhteystiedot"
#: webapp/templates/event_calendar.html:10 webapp/templates/navigation.html:12
#: webapp/templates/event_calendar.html:10 webapp/templates/navigation.html:11
msgid "Event calendar"
msgstr "Tapahtumakalenteri"
@@ -1140,19 +1146,19 @@ msgstr "Infonäyttöjen hallintapaneeli"
msgid "Kaehmy application"
msgstr "Kaehmy"
#: webapp/templates/jobs.html:10 webapp/templates/navigation.html:28
#: webapp/templates/jobs.html:10 webapp/templates/navigation.html:27
msgid "Jobs"
msgstr "Työpaikat"
#: webapp/templates/navigation.html:6
#: webapp/templates/navigation.html:5
msgid "Guild"
msgstr "Kilta"
#: webapp/templates/navigation.html:18 webapp/templates/sosso.html:10
#: webapp/templates/navigation.html:17 webapp/templates/sosso.html:10
msgid "Sössö"
msgstr "Sössö"
#: webapp/templates/navigation.html:25
#: webapp/templates/navigation.html:24
msgid "Corporate"
msgstr "Yritys"
-10
View File
@@ -103,16 +103,6 @@ class Member(BaseMember):
verbose_name = _('Member')
verbose_name_plural = _('Members')
def last_paid(self):
"""Return member's last payment."""
try:
payments = Payment.objects.filter(member=self)
latest = payments.latest('date')
date = latest.date
return date
except Payment.DoesNotExist:
return None
@staticmethod
def from_array(array):
"""Create member from array."""
+14 -2
View File
@@ -2,6 +2,8 @@
import django_tables2 as tables
from django.utils.translation import ugettext as _
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import F, OuterRef, Subquery
from members.models import Member, Payment, Request
@@ -9,8 +11,7 @@ from members.models import Member, Payment, Request
class MemberTable(tables.Table):
"""Table for member."""
last_paid = tables.DateTimeColumn(
accessor='last_paid', verbose_name=_('Last paid'))
last_paid = tables.DateTimeColumn(verbose_name=_('Last paid'))
options = tables.TemplateColumn(
('<a class="data-table-button btn btn-primary" '
@@ -25,6 +26,17 @@ class MemberTable(tables.Table):
model = Member
def render_last_paid(self, record):
try:
return record.payments.filter(member=record).latest('date').date.strftime('%e.%m.%Y %H:%M')
except ObjectDoesNotExist:
return record.created.strftime('%e.%m.%Y %H:%M') + _(" (not paid)")
def order_last_paid(self, queryset, is_descending):
latest = Payment.objects.filter(member=OuterRef('pk')).order_by('-date')
queryset = queryset.annotate(last_paid=Subquery(latest.values('date')[:1])).order_by(('-' if is_descending else '') + 'last_paid')
return (queryset, True)
class PaymentTable(tables.Table):
"""Table for payments."""
+18
View File
@@ -0,0 +1,18 @@
{% extends "members:base.html" %}
{% load static %}
{% load i18n %}
{% block content %}
<div>
<div>
<h3>{% trans "Error" %}</h3>
</div>
<div class="alert alert-danger">
{{ error|safe }}
</div>
<div>
<button onclick="window.history.back();" class="btn btn-primary">{% trans "Back" %}</button>
</div>
</div>
{% endblock content %}
-1
View File
@@ -27,7 +27,6 @@ from smtplib import SMTPAuthenticationError
from members.models import Member, Request, Payment
from members.forms import MemberForm, PaymentForm, ApplicationForm, CSVValidationError
from members.tables import MemberTable, PaymentTable, RequestTable
@receiver(post_save, sender=Request)