fnp
/
django-migdal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix for django 1.10 (= in template)
[django-migdal.git]
/
migdal
/
forms.py
diff --git
a/migdal/forms.py
b/migdal/forms.py
index
e7d6394
..
649980c
100644
(file)
--- a/
migdal/forms.py
+++ b/
migdal/forms.py
@@
-2,13
+2,14
@@
# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
+from django.contrib.sites.models import Site
+from django.core.mail import mail_managers
from django import forms
from django import forms
+from django import template
from django.utils.translation import ugettext_lazy as _, get_language
from django.utils.translation import ugettext_lazy as _, get_language
+from slugify import slugify
from migdal.models import Entry
from migdal import app_settings
from migdal.models import Entry
from migdal import app_settings
-from fnpdjango.utils.text import slughifi
-from django.core.mail import mail_managers
-from django import template
def get_submit_form(*args, **kwargs):
def get_submit_form(*args, **kwargs):
@@
-17,8
+18,7
@@
def get_submit_form(*args, **kwargs):
class SubmitForm(forms.ModelForm):
class Meta:
model = Entry
class SubmitForm(forms.ModelForm):
class Meta:
model = Entry
- fields = ['title_%s' % lang, 'lead_%s' % lang,
- 'author', 'author_email', 'categories']
+ fields = ['title_%s' % lang, 'lead_%s' % lang, 'author', 'author_email', 'categories']
required = ['title_%s' % lang]
def __init__(self, *args, **kwargs):
required = ['title_%s' % lang]
def __init__(self, *args, **kwargs):
@@
-33,7
+33,7
@@
def get_submit_form(*args, **kwargs):
def clean(self):
data = super(SubmitForm, self).clean()
data['type'] = app_settings.TYPE_SUBMIT
def clean(self):
data = super(SubmitForm, self).clean()
data['type'] = app_settings.TYPE_SUBMIT
- orig_slug = slug
hifi(data.get('title_%s' % lang, ''))
+ orig_slug = slug
ify(data.get('title_%s' % lang, ''))[:47]
slug = orig_slug
number = 2
while Entry.objects.filter(**{'slug_%s' % lang: slug}).exists():
slug = orig_slug
number = 2
while Entry.objects.filter(**{'slug_%s' % lang: slug}).exists():
@@
-53,9
+53,13
@@
def get_submit_form(*args, **kwargs):
setattr(entry, f, self.cleaned_data[f])
entry.save()
entry = super(SubmitForm, self).save(*args, **kwargs)
setattr(entry, f, self.cleaned_data[f])
entry.save()
entry = super(SubmitForm, self).save(*args, **kwargs)
- mail_managers(u"Nowy wpis",
+ mail_managers(
+ u"Nowy wpis",
template.loader.get_template(
'migdal/mail/manager_new_entry.txt').render(
template.loader.get_template(
'migdal/mail/manager_new_entry.txt').render(
- template.Context({'object': entry})))
+ template.Context({
+ 'object': entry,
+ 'site': Site.objects.get_current(),
+ })))
- return SubmitForm(*args, **kwargs)
\ No newline at end of file
+ return SubmitForm(*args, **kwargs)