-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
admin with grappelli, html modification
- Loading branch information
1 parent
739a8ff
commit a4a1676
Showing
63 changed files
with
2,214 additions
and
508 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,45 +12,34 @@ | |
DATE_FORMAT = "%d-%m-%Y" | ||
TIME_FORMAT = "%H:%M:%S" | ||
|
||
|
||
@receiver(post_save, sender=BarBalance) | ||
def bar_handler(sender, **kwargs): | ||
saved_balance = kwargs['instance'] | ||
|
||
if saved_balance.operation == CLOSING: | ||
subject = '' | ||
template = get_template('closing_mail.html') | ||
|
||
print "saved_balance parent:" , saved_balance.parent | ||
d = get_bar_summary(saved_balance) | ||
context = Context(d) | ||
content = template.render(context) | ||
|
||
if ('warning' in d): | ||
subject += 'WARNING ' | ||
subject += 'riepilogo bar '+saved_balance.parent.date.strftime("%d/%m/%Y") | ||
|
||
msg = EmailMessage(subject, content, '[email protected]', to=settings.EMAIL_NOTIFICATION_LIST) | ||
msg.content_subtype = "html" | ||
msg.send() | ||
template = get_template('closing_mail.html') | ||
context = Context(d) | ||
content = template.render(context) | ||
subject = 'WARNING riepilogo bar '+saved_balance.parent.date.strftime("%d/%m/%Y") | ||
msg = EmailMessage(subject, content, '[email protected]', to=settings.EMAIL_NOTIFICATION_LIST) | ||
msg.content_subtype = "html" | ||
msg.send() | ||
|
||
@receiver(post_save, sender=SmallBalance) | ||
def bar_handler(sender, **kwargs): | ||
def small_handler(sender, **kwargs): | ||
saved_balance = kwargs['instance'] | ||
|
||
if saved_balance.operation == CASHPOINT: | ||
subject = '' | ||
template = get_template('base/smallbalance_mail.html') | ||
|
||
print "saved_balance parent:" , saved_balance.parent | ||
d = get_small_summary(saved_balance) | ||
context = Context(d) | ||
content = template.render(context) | ||
|
||
if ('warning' in d): | ||
subject += 'WARNING ' | ||
subject += 'riepilogo interregno '+saved_balance.date.strftime("%d/%m/%Y") | ||
|
||
msg = EmailMessage(subject, content, '[email protected]', to=settings.EMAIL_NOTIFICATION_LIST) | ||
msg.content_subtype = "html" | ||
msg.send() | ||
template = get_template('base/smallbalance_mail.html') | ||
context = Context(d) | ||
content = template.render(context) | ||
subject = 'WARNING riepilogo interregno '+saved_balance.date.strftime("%d/%m/%Y") | ||
msg = EmailMessage(subject, content, '[email protected]', to=settings.EMAIL_NOTIFICATION_LIST) | ||
msg.content_subtype = "html" | ||
msg.send() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from django import template | ||
from django.contrib.auth.models import User | ||
import datetime | ||
|
||
register = template.Library() | ||
|
||
""" | ||
namefile: usertags.py | ||
You would need a template nest for every method, for example to online_users. | ||
/templates/tag/online_users.html | ||
{% if users %} | ||
<ul> | ||
{% for user in users %} | ||
<li>{{user.username}}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
to load | ||
{% load usertags %} | ||
{% online_users 5 %} | ||
{% last_registers 5 %} | ||
{% last_logins 5 %} | ||
""" | ||
|
||
#@register.inclusion_tag('tags/online_users.html') | ||
@register.assignment_tag | ||
def online_users(num): | ||
""" | ||
Show user that has been login an hour ago. | ||
""" | ||
two_hour_ago = datetime.datetime.now() - datetime.timedelta(hours=2) | ||
sql_datetime = datetime.datetime.strftime(two_hour_ago, '%Y-%m-%d %H:%M:%S') | ||
users = User.objects.filter(last_login__gt=sql_datetime, | ||
is_active__exact=1).order_by('-last_login')[:num] | ||
return users | ||
|
||
#@register.inclusion_tag('tags/last_registers.html') | ||
@register.assignment_tag | ||
def last_registers(num): | ||
""" | ||
Show last registered users. | ||
""" | ||
users = User.objects.filter(is_active__exact=1).order_by('-date_joined')[:num] | ||
return users | ||
|
||
#@register.inclusion_tag('tags/last_logins.html') | ||
@register.assignment_tag | ||
def last_logins(num): | ||
""" | ||
Show last logins ... | ||
""" | ||
users = User.objects.filter(is_active__exact=1).order_by('-last_login')[:num] | ||
return users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.