-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from coders4help/develop
Release 3.0.0 Merge
- Loading branch information
Showing
122 changed files
with
66,998 additions
and
1,687 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ db.sqlite3 | |
/htmlcov | ||
/.coverage | ||
*.log | ||
.cache |
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 |
---|---|---|
@@ -1,11 +1,48 @@ | ||
# coding: utf-8 | ||
|
||
from django.contrib import admin | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from .models import UserAccount | ||
|
||
|
||
@admin.register(UserAccount) | ||
class UserAccountAdmin(admin.ModelAdmin): | ||
list_display = (u'id', 'user') | ||
|
||
def get_user_first_name(self, obj): | ||
return obj.user.first_name | ||
|
||
get_user_first_name.short_description = _(u'first name') | ||
get_user_first_name.admin_order_field = 'user__first_name' | ||
|
||
|
||
def get_user_last_name(self, obj): | ||
return obj.user.last_name | ||
|
||
get_user_last_name.short_description = _(u'first name') | ||
get_user_last_name.admin_order_field = 'user__last_name' | ||
|
||
def get_user_email(self, obj): | ||
return obj.user.email | ||
|
||
get_user_email.short_description = _(u'email') | ||
get_user_email.admin_order_field = 'user__email' | ||
|
||
list_display = ( | ||
'user', | ||
'get_user_email', | ||
'get_user_first_name', | ||
'get_user_last_name' | ||
) | ||
raw_id_fields = ('user',) | ||
search_fields = ( | ||
'user__username', | ||
'user__email', | ||
'user__last_name', | ||
'user__first_name' | ||
) | ||
|
||
list_filter = ( | ||
'user__is_active', | ||
'user__is_staff', | ||
) |
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 |
---|---|---|
@@ -1,33 +1,28 @@ | ||
# coding=utf-8 | ||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
|
||
from datetime import date, timedelta | ||
|
||
from registration.models import RegistrationProfile | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Cleanup expired registrations' | ||
|
||
OPT_SIMULATE = 'dry-run' | ||
def handle(self, *args, **options): | ||
profiles = RegistrationProfile.objects \ | ||
.exclude(activation_key=RegistrationProfile.ACTIVATED) \ | ||
.prefetch_related('user', 'user__account') \ | ||
.exclude(user__is_active=True) \ | ||
.filter(user__date_joined__lt=(date.today() - timedelta(settings.ACCOUNT_ACTIVATION_DAYS))) | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument(''.join(['--', self.OPT_SIMULATE]), | ||
action='store_true', | ||
dest=self.OPT_SIMULATE, | ||
default=False, | ||
help='Only print registrations that would be deleted') | ||
if settings.DEBUG: | ||
self.stderr.write(u'SQL: {}'.format(profiles.query)) | ||
|
||
def handle(self, *args, **options): | ||
self.stdout.write('Deleting expired user registrations') | ||
dry_run = True if self.OPT_SIMULATE in options and options[ | ||
self.OPT_SIMULATE] else False | ||
if dry_run: | ||
user_count, reg_profile_count = 0, 0 | ||
for profile in RegistrationProfile.objects.select_related( | ||
'user').exclude(user__is_active=True): | ||
if profile.activation_key_expired(): | ||
user_count += 1 | ||
reg_profile_count += 1 | ||
print "Would delete {} User and {} RegistrationProfile objects".format( | ||
user_count, reg_profile_count) | ||
else: | ||
RegistrationProfile.objects.delete_expired_users() | ||
for profile in profiles: | ||
if hasattr(profile, 'user'): | ||
if hasattr(profile.user, 'account'): | ||
profile.user.account.delete() | ||
profile.user.delete() | ||
profile.delete() |
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,4 @@ | ||
# coding: utf-8 | ||
|
||
def skip(*_, **__): | ||
pass |
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,14 @@ | ||
# coding: utf-8 | ||
|
||
# coding: utf-8 | ||
|
||
from django import template | ||
|
||
from django.contrib.sites.shortcuts import get_current_site | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.assignment_tag | ||
def request_site(request): | ||
return get_current_site(request_site) |
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
Empty file.
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,67 @@ | ||
# coding: utf-8 | ||
from django.conf import settings | ||
|
||
from django.contrib import admin | ||
from django.contrib.flatpages.admin import FlatPageAdmin | ||
from django.contrib.flatpages.models import FlatPage | ||
from django.utils.html import format_html | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from . import models, forms | ||
|
||
|
||
class FlatPageStyleInline(admin.StackedInline): | ||
model = models.FlatPageExtraStyle | ||
verbose_name = _('additional CSS') | ||
verbose_name_plural = _('additional CSS') | ||
template = 'flatpages/additional_flat_page_style_inline.html' | ||
|
||
|
||
class FlatPageTranslationInline(admin.StackedInline): | ||
model = models.FlatPageTranslation | ||
form = forms.FlatPageTranslationFormWithHTMLEditor | ||
verbose_name = _('translation') | ||
verbose_name_plural = _('translations') | ||
extra = 0 | ||
|
||
|
||
class FlatPageTranslationAdmin(FlatPageAdmin): | ||
inlines = [ | ||
FlatPageStyleInline, | ||
FlatPageTranslationInline, | ||
] | ||
|
||
form = forms.FlatPageFormWithHTMLEditor | ||
list_filter = ('sites', 'registration_required',) | ||
list_display = ( | ||
'title', | ||
'url', | ||
'registration_required', | ||
'get_translations', | ||
) | ||
search_fields = ('url', 'title') | ||
|
||
def get_translations(self, obj): | ||
translations = list(obj.translations.all()) | ||
trans_list = None | ||
if translations: | ||
translations = sorted( | ||
t.get_language_display() for t in translations) | ||
|
||
trans_list = u'<ul>{}</ul>'.format( | ||
u'\n'.join(u'<li>{}</li>'.format(t) for t in translations) | ||
) | ||
return format_html( | ||
u'{}/{}:<br />{}'.format( | ||
len(translations), | ||
len(settings.LANGUAGES), | ||
trans_list or _('No translation available') | ||
) | ||
) | ||
|
||
get_translations.allow_tags = True | ||
get_translations.short_description = _('translations') | ||
|
||
|
||
admin.site.unregister(FlatPage) | ||
admin.site.register(FlatPage, FlatPageTranslationAdmin) |
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,18 @@ | ||
# coding: utf-8 | ||
from ckeditor.widgets import CKEditorWidget | ||
from django.contrib.flatpages.forms import FlatpageForm | ||
from django import forms | ||
|
||
from content.models import FlatPageTranslation | ||
|
||
|
||
class FlatPageTranslationFormWithHTMLEditor(forms.ModelForm): | ||
content = forms.CharField(widget=CKEditorWidget()) | ||
|
||
class Meta: | ||
fields = '__all__' | ||
model = FlatPageTranslation | ||
|
||
|
||
class FlatPageFormWithHTMLEditor(FlatpageForm): | ||
content = forms.CharField(widget=CKEditorWidget()) |
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,44 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('flatpages', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='FlatPageExtraStyle', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('css', models.TextField(verbose_name='additional CSS', blank=True)), | ||
('flatpage', models.OneToOneField(related_name='extra_style', verbose_name='additional style', to='flatpages.FlatPage')), | ||
], | ||
options={ | ||
'verbose_name': 'additional flat page style', | ||
'verbose_name_plural': 'additional flat page styles', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='FlatPageTranslation', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('language', models.CharField(max_length=20, verbose_name='language', choices=[(b'de', 'German'), (b'en', 'English'), (b'hu', 'Hungarian'), (b'sv', 'Swedish')])), | ||
('title', models.CharField(max_length=200, verbose_name='title', blank=True)), | ||
('content', models.TextField(verbose_name='content', blank=True)), | ||
('flatpage', models.ForeignKey(related_name='translations', verbose_name='flat page', to='flatpages.FlatPage')), | ||
], | ||
options={ | ||
'verbose_name': 'flat page translation', | ||
'verbose_name_plural': 'flat page translations', | ||
}, | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='flatpagetranslation', | ||
unique_together=set([('flatpage', 'language')]), | ||
), | ||
] |
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,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('content', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='flatpagetranslation', | ||
name='language', | ||
field=models.CharField(max_length=20, verbose_name='language', choices=[(b'en', 'English'), (b'de', 'German'), (b'el', 'Greek'), (b'hu', 'Hungarian'), (b'sv', 'Swedish')]), | ||
), | ||
] |
Empty file.
Oops, something went wrong.