Skip to content

Commit

Permalink
Merge branch 'master' into 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jsayles committed Jun 21, 2017
2 parents 0a79ccc + 745c356 commit 67198d3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 40 deletions.
2 changes: 2 additions & 0 deletions nadine/management/commands/send_user_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User
from django.utils import timezone

from members.models import UserNotification
from nadine import email


class Command(BaseCommand):
Expand Down
2 changes: 1 addition & 1 deletion nadine/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def search(self, search_string, active_only=False):
lname_query = lname_query | Q(last_name__icontains=term)
user_query = user_query.filter(fname_query | lname_query)

return user_query.order_by('first_name')
return user_query.order_by('first_name', 'last_name')

def by_email(self, email):
email_address = EmailAddress.objects.filter(email=email).first()
Expand Down
1 change: 0 additions & 1 deletion nadine/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
'interlink',
'doors.keymaster',
# Other Applications
'easy_pdf',
'jsignature',
'taggit_templatetags2',
'taggit',
Expand Down
22 changes: 8 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
Django>=1.11,<2.0
Pillow==4.1.1
psycopg2==2.7.1
django-localflavor==1.4.1
django-localflavor==1.5
django-localflavor-us==1.1
django-taggit==0.22.1
django-taggit-templatetags2==1.6.1
django-crontab==0.7.1
mailchimp==2.0.9
requests==2.14.2
cryptography==1.8.1
requests==2.17.3
cryptography==1.9
suds-jurko==0.6
python-slugify==1.2.4


For document signing & PDFs
# For document signing & PDFs
html5lib==1.0b10
django-jsignature==0.8
weasyprint==0.36
weasyprint==0.38

# A few handy tools
django-debug-toolbar
pip-review

# Libraries for Xero
pyxero==0.8.0
PyJWT==1.4.2
PyJWT==1.5.0

# Libraries for Arpwatch
pysnmp==4.3.5
pysnmp==4.3.7
pysnmp-mibs==0.1.6

# TODO - Evaluate use of these libraries
feedparser
#py4j==0.9.2
#django-tastypie==0.12.2

# For the documentation:
sphinx==1.6.1
sphinx==1.6.2
sphinx-rtd-theme==0.2.4
recommonmark==0.4.0
pycodestyle==2.3.1
2 changes: 1 addition & 1 deletion tablet/static/signature.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ canvas.jSignature {
input.resetButton {
float: left;
margin: 12px 0 -44px 520px;
}
}
27 changes: 18 additions & 9 deletions tablet/templates/tablet/signature_render.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@

<head>
<style>
@page {
size: letter portrait;
body {
margin-top: -50px;
margin-left: -100px;
margin-right: -100px;
margin-bottom: -50px;
}
.page img {
width:8.5in;
}
.signature_box table {
margin-left: 120px;
width: 500px;
}
.signature_box th {
margin-left: 100px;
width: 200px;
width: 100px;
vertical-align: bottom;
}
.signature_box td {
Expand All @@ -18,18 +27,18 @@
vertical-align: bottom;
}
.signature_box img{
zoom: 50%;
width: 200px;
}
</style>
</head>

<body>
<div id="page1_content">
<img src="/media/documents/{{doc_type}}1.png" width="100%"/>
<div class="page" id="page1_content">
<img src="/media/documents/{{doc_type}}1.png"/>
</div>
<pdf:nextpage>
<div id="page2_content">
<img src="/media/documents/{{doc_type}}2.png" width="100%"/>
<div class="page" id="page2_content">
<img src="/media/documents/{{doc_type}}2.png"/>
<div class="signature_box">
<table>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion tablet/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
url(r'^(?P<username>[^/]+)/signin/$', views.signin_user, name='signin_user'),
url(r'^(?P<username>[^/]+)/guestof/(?P<paid_by>[^/]+)$', views.signin_user_guest, name='signin_guest'),
url(r'^(?P<username>[^/]+)/documents/$', views.document_list, name='document_list'),
url(r'^(?P<username>[^/]+)/document/(?P<doc_type>[^/]+)$', views.document_view, name='document_view'),
url(r'^(?P<username>[^/]+)/document/(?P<doc_type>[^/]+)/$', views.document_view, name='document_view'),
url(r'^(?P<username>[^/]+)/signature/(?P<doc_type>[^/]+)/$', views.signature_capture, name='sig_capture'),
url(r'^(?P<username>[^/]+)/signature/(?P<doc_type>[^/]+)/(?P<signature_file>[^/]+)$', views.signature_render, name='sig_render'),
]
Expand Down
25 changes: 12 additions & 13 deletions tablet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import logging
import uuid
from datetime import date, datetime, time, timedelta
from weasyprint import HTML, CSS

from django.conf import settings
from django.template import RequestContext
from django.template.loader import get_template
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse, resolve
from django.contrib.auth.decorators import login_required
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.sites.models import Site
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from django.utils.timezone import localtime, now

from weasyprint import HTML, CSS

from nadine import email
from nadine.utils import mailgun
Expand All @@ -26,8 +28,6 @@
from members.models import MOTD
from .forms import SignatureForm

from easy_pdf.rendering import render_to_pdf, render_to_pdf_response

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -90,7 +90,7 @@ def user_signin(request, username):
# They have a desk so they can't sign in
can_signin = False
else:
signins_today = CoworkingDay.objects.filter(user=user, visit_date=timezone.localtime(timezone.now()).date())
signins_today = CoworkingDay.objects.filter(user=user, visit_date=localtime(now()).date())
if signins_today.count() > 0:
can_signin = False

Expand Down Expand Up @@ -143,7 +143,7 @@ def signin_user_guest(request, username, paid_by):
user = get_object_or_404(User, username=username)
day = CoworkingDay()
day.user = user
day.visit_date = timezone.localtime(timezone.now()).date()
day.visit_date = localtime(now()).date()
# Only proceed if they haven't signed in already
if CoworkingDay.objects.filter(user=user, visit_date=day.visit_date).count() == 0:
if paid_by:
Expand Down Expand Up @@ -209,7 +209,7 @@ def document_view(request, username, doc_type):

def signature_capture(request, username, doc_type):
user = get_object_or_404(User, username=username)
today = timezone.localtime(timezone.now()).date()
today = localtime(now()).date()
form = SignatureForm(request.POST or None)
if form and form.has_signature():
signature_file = form.save_signature()
Expand All @@ -220,18 +220,17 @@ def signature_capture(request, username, doc_type):

def signature_render(request, username, doc_type, signature_file):
user = get_object_or_404(User, username=username)
today = timezone.localtime(timezone.now()).date()
today = localtime(now()).date()
pdf_args = {'name': user.get_full_name, 'date': today, 'doc_type': doc_type, 'signature_file': signature_file}
htmltext = get_template('tablet/signature_render.html')
signature_html = htmltext.render(pdf_args)
pdf_file = HTML(string=signature_html, base_url=request.build_absolute_uri()).write_pdf()
if 'save_file' in request.GET:
# Save the PDF as a file and redirect them back to the document list
htmltext = get_template('tablet/signature_render.html')
signature_html = htmltext.render(pdf_args)
pdf_file = HTML(string=signature_html, base_url=request.build_absolute_uri()).write_pdf()
upload_file = FileUpload.objects.pdf_from_string(user, pdf_file, doc_type, user)
os.remove(os.path.join(settings.MEDIA_ROOT, "signatures/%s" % signature_file))
return HttpResponseRedirect(reverse('tablet:document_list', kwargs={'username': user.username}))

return render_to_pdf_response(request, 'tablet/signature_render.html', pdf_args)
return HttpResponse(pdf_file, content_type='application/pdf')


# Copyright 2017 Office Nomads LLC (http://www.officenomads.com/) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

0 comments on commit 67198d3

Please sign in to comment.