Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

paper reminders support

  • Loading branch information...
commit b85d27011db703ea433050fa8143fcb241b3f825 1 parent dbd643b
@annttu annttu authored
View
1  .gitignore
@@ -10,3 +10,4 @@ local_settings.py
*.mo
/env
django.wsgi
+muistutusviesti.tex
View
1  membership/models.py
@@ -41,7 +41,6 @@ class PaymentAttachedError(Exception): pass
('D', _('Deleted')))
MEMBER_STATUS_DICT = tupletuple_to_dict(MEMBER_STATUS)
-
BILL_TYPES = (
('E', _('Email')),
('P', _('Paper')),
View
9 membership/urls.py
@@ -1,9 +1,11 @@
from django.conf.urls.defaults import patterns, url
from django.contrib.auth.decorators import permission_required
from django.shortcuts import redirect
+from django.db.models import Count
import django.views.generic.list_detail
from membership.models import Contact, Membership, Payment, BillingCycle
from sikteeri.settings import ENTRIES_PER_PAGE
+from management.commands.paper_reminders import get_data as get_paper_reminders
# Shortcuts
payments = Payment.objects.all().order_by('-payment_day', '-id')
@@ -114,6 +116,13 @@
'template_name': 'membership/bill_list.html',
'template_object_name': 'cycle',
'paginate_by': ENTRIES_PER_PAGE}, name='unpaid_cycle_list'),
+ url(r'bills/locked/$', 'membership.views.billing_object_list',
+ {'queryset': get_paper_reminders(),
+ 'template_name': 'membership/bill_list.html',
+ 'template_object_name': 'cycle',
+ 'paginate_by': ENTRIES_PER_PAGE}, name='locked_cycle_list'),
+ url(r'bills/print_reminders/$', 'membership.views.print_reminders',
+ name='print_reminders'),
url(r'payments/$', 'membership.views.billing_object_list',
{'queryset': payments,
View
35 membership/views.py
@@ -2,6 +2,7 @@
import logging
import json
+from os import remove as remove_file
from sikteeri import settings
from membership.models import Contact, Membership, MEMBER_TYPES_DICT, Bill,\
BillingCycle, Payment
@@ -31,6 +32,7 @@
from services.views import check_alias_availability, validate_alias
from management.commands.csvbills import process_csv as payment_csv_import
+from management.commands.paper_reminders import generate_reminders, get_data as get_paper_reminders
from decorators import trusted_host_required
from django.db.models.query_utils import Q
@@ -506,6 +508,39 @@ class PaymentCSVForm(Form):
'import_messages': import_messages},
context_instance=RequestContext(request))
+@permission_required('membership.read_bills')
+def print_reminders(request, **kwargs):
+ output_messages = []
+ if request.method == 'POST':
+ try:
+ if 'marksent' in request.POST:
+ for billing_cycle in get_paper_reminders().all():
+ bill = Bill(billingcycle=billing_cycle, type='P')
+ bill.reminder_count = billing_cycle.bill_set.count()
+ bill.save()
+ output_messages.append(_('Reminders marked as sent'))
+ else:
+ pdffile = generate_reminders()
+ f = open(pdffile, 'r')
+ pdf = f.read()
+ f.close()
+ try:
+ # remove file from tmp
+ remove_file(pdffile)
+ except OSError:
+ pass
+ response = HttpResponse(pdf, content_type='application/pdf')
+ response['Content-Disposition'] = 'attachment; filename=reminders.pdf'
+ return response
+ except RuntimeError:
+ output_messages.append(_('Error processing PDF'))
+ except IOError:
+ output_messages.append(_('Cannot open PDF file'))
+ return render_to_response('membership/print_reminders.html',
+ {'title': _("Print paper reminders"),
+ 'output_messages': output_messages,
+ 'count': get_paper_reminders().count()},
+ context_instance=RequestContext(request))
@permission_required('membership.manage_bills')
def billingcycle_edit(request, id, template_name='membership/entity_edit.html'):
View
2  sikteeri/local_settings.py.template
@@ -129,3 +129,5 @@ LOGGING = {
# "Send" emails to a mbox file through a mock email backend
#EMAIL_BACKEND = 'mboxemailbackend.EmailBackend'
#EMAIL_MBOX_FILE_PATH = 'sikteeri.mbox' # change this to a proper location
+
+#PAPER_REMINDER_TEMPLATE = 'myreminder.tex'
View
3  sikteeri/settings.py
@@ -111,6 +111,9 @@
# Show 30 items per page in listview
ENTRIES_PER_PAGE=30
+# path to paper reminder latex template
+PAPER_REMINDER_TEMPLATE = None
+
from local_settings import *
# Is this the right way to do this?
View
1  sikteeri/templates/menu.html
@@ -41,6 +41,7 @@
<li><a href="{% url unknown_payment_list %}">{% trans "Unknown payments" %}</a></li>
<li><a href="{% url ignored_payment_list %}">{% trans "Ignored payments" %}</a></li>
<li><a href="{% url payment_list %}">{% trans "All payments" %}</a></li>
+ <li><a href="{% url print_reminders %}">{% trans "Print reminders" %}</a></li>
{% if perms.membership.can_import_payments %}
<li><a href="{% url import_payments %}">{% trans "Import payments" %}</a></li>
{% endif %}
Please sign in to comment.
Something went wrong with that request. Please try again.