fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
91eb62b
)
Minor fixes.
author
Radek Czajka
<rczajka@rczajka.pl>
Wed, 26 Feb 2020 10:11:09 +0000
(10:11 +0000)
committer
Radek Czajka
<rczajka@rczajka.pl>
Wed, 26 Feb 2020 10:11:09 +0000
(10:11 +0000)
src/messaging/admin.py
patch
|
blob
|
history
src/messaging/management/commands/messaging_send.py
patch
|
blob
|
history
src/messaging/models.py
patch
|
blob
|
history
src/wolnelektury/static/css/new.book.css
patch
|
blob
|
history
diff --git
a/src/messaging/admin.py
b/src/messaging/admin.py
index
9ac76b5
..
4ea538f
100644
(file)
--- a/
src/messaging/admin.py
+++ b/
src/messaging/admin.py
@@
-65,7
+65,20
@@
class EmailSentAdmin(admin.ModelAdmin):
admin.site.register(models.EmailSent, EmailSentAdmin)
admin.site.register(models.EmailSent, EmailSentAdmin)
+class ContactEmailSentInline(admin.TabularInline):
+ model = models.EmailSent
+ fields = ['timestamp', 'template', 'subject']
+ readonly_fields = ['timestamp', 'template', 'subject']
+ extra = 0
+ can_delete = False
+ show_change_link = True
+
+ def has_add_permission(self, request, obj):
+ return False
+
+
class ContactAdmin(admin.ModelAdmin):
class ContactAdmin(admin.ModelAdmin):
+ inlines = [ContactEmailSentInline]
list_filter = ['level']
list_display = ['email', 'level', 'since', 'expires_at']
search_fields = ['email']
list_filter = ['level']
list_display = ['email', 'level', 'since', 'expires_at']
search_fields = ['email']
diff --git
a/src/messaging/management/commands/messaging_send.py
b/src/messaging/management/commands/messaging_send.py
index
82743f2
..
2fa8176
100644
(file)
--- a/
src/messaging/management/commands/messaging_send.py
+++ b/
src/messaging/management/commands/messaging_send.py
@@
-9,6
+9,6
@@
class Command(BaseCommand):
parser.add_argument('--dry-run', action='store_true', help='Dry run')
def handle(self, *args, **options):
parser.add_argument('--dry-run', action='store_true', help='Dry run')
def handle(self, *args, **options):
- for et in EmailTemplate.
objects.order_by('min_days_since').filter(is_active=True
):
+ for et in EmailTemplate.
get_current().order_by('min_days_since'
):
et.run(verbose=True, dry_run=options['dry_run'])
et.run(verbose=True, dry_run=options['dry_run'])
diff --git
a/src/messaging/models.py
b/src/messaging/models.py
index
c929228
..
fccd647
100644
(file)
--- a/
src/messaging/models.py
+++ b/
src/messaging/models.py
@@
-1,10
+1,11
@@
+from datetime import timedelta
from django.apps import apps
from django.conf import settings
from django.core.mail import send_mail
from django.db import models
from django.template import Template, Context
from django.urls import reverse
from django.apps import apps
from django.conf import settings
from django.core.mail import send_mail
from django.db import models
from django.template import Template, Context
from django.urls import reverse
-from django.utils.timezone import now
+from django.utils.timezone import now
, get_current_timezone
from django.utils.translation import ugettext_lazy as _
from sentry_sdk import capture_exception
from catalogue.utils import get_random_hash
from django.utils.translation import ugettext_lazy as _
from sentry_sdk import capture_exception
from catalogue.utils import get_random_hash
@@
-37,6
+38,16
@@
class EmailTemplate(models.Model):
def __str__(self):
return '%s (%+d)' % (self.get_state_display(), self.min_days_since or 0)
def __str__(self):
return '%s (%+d)' % (self.get_state_display(), self.min_days_since or 0)
+ @classmethod
+ def get_current(cls, time=None):
+ time = (time or now()).astimezone(get_current_timezone())
+ weekday = time.isoweekday()
+ qs = cls.objects.filter(is_active=True)
+ qs = qs.exclude(min_hour__gt=time.hour).exclude(max_hour__lte=time.hour)
+ qs = qs.exclude(min_day_of_month__gt=time.day).exclude(max_day_of_month__lte=time.day)
+ qs = qs.exclude(**{f'dow_{weekday}': False})
+ return qs
+
def run(self, time=None, verbose=False, dry_run=False):
state = self.get_state(time=time)
contacts = state.get_contacts()
def run(self, time=None, verbose=False, dry_run=False):
state = self.get_state(time=time)
contacts = state.get_contacts()
@@
-71,7
+82,7
@@
class EmailTemplate(models.Model):
body = Template(body_template).render(ctx)
if verbose:
body = Template(body_template).render(ctx)
if verbose:
- print(
contact.email, subject
)
+ print(
self.pk, subject, contact.email
)
if not dry_run:
try:
send_mail(subject, body, settings.CONTACT_EMAIL, [contact.email], fail_silently=False)
if not dry_run:
try:
send_mail(subject, body, settings.CONTACT_EMAIL, [contact.email], fail_silently=False)
@@
-166,5
+177,5
@@
class EmailSent(models.Model):
ordering = ('-timestamp',)
def __str__(self):
ordering = ('-timestamp',)
def __str__(self):
- return '%s %s' % (self.email, self.timestamp)
+ return '%s %s' % (self.
contact.
email, self.timestamp)
diff --git
a/src/wolnelektury/static/css/new.book.css
b/src/wolnelektury/static/css/new.book.css
index
a1d45c8
..
689d99f
100644
(file)
--- a/
src/wolnelektury/static/css/new.book.css
+++ b/
src/wolnelektury/static/css/new.book.css
@@
-14,6
+14,12
@@
img {
max-width: 37.5rem;
margin-top: 1em;
}
max-width: 37.5rem;
margin-top: 1em;
}
+.animacja {
+ margin-top: 1em;
+}
+.animacja img {
+ margin-top: 0;
+}
/* ================================== */
/* = Header with logo and menu = */
/* ================================== */
/* = Header with logo and menu = */