diff --git a/opentech/apply/funds/blocks.py b/opentech/apply/funds/blocks.py index 6942a19fa97dbca8fdb7d7c24de19077ea39cae4..2fe74b168f1f930f570cf1361462e9220c356904 100644 --- a/opentech/apply/funds/blocks.py +++ b/opentech/apply/funds/blocks.py @@ -153,10 +153,15 @@ class EmailBlock(MustIncludeFieldBlock): description = 'The applicant email address' widget = forms.EmailInput + class Meta: + icon = 'user' + class FullNameBlock(MustIncludeFieldBlock): name = 'full_name' description = 'Full name' + class Meta: + icon = 'mail' REQUIRED_BLOCK_NAMES = [block.name for block in MustIncludeFieldBlock.__subclasses__()] diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index 2ec4d4248c52b0c87b752b9a9207fc715e5603d9..0e9c76394df926818979981ab027f904edafd669 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -19,10 +19,13 @@ from wagtail.wagtailadmin.edit_handlers import ( FieldRowPanel, InlinePanel, MultiFieldPanel, + ObjectList, StreamFieldPanel, + TabbedInterface ) + from wagtail.wagtailcore.fields import StreamField -from wagtail.wagtailcore.models import Orderable +from wagtail.wagtailcore.models import Orderable, Page from wagtail.wagtailforms.models import AbstractEmailForm, AbstractFormSubmission from opentech.apply.stream_forms.models import AbstractStreamForm @@ -125,6 +128,9 @@ class DefinableWorkflowStreamForm(AbstractEmailForm, AbstractStreamForm): content_panels = AbstractStreamForm.content_panels + [ FieldPanel('workflow'), InlinePanel('forms', label="Forms"), + ] + + email_confirmation_panels = [ MultiFieldPanel( [ FieldRowPanel([ @@ -135,10 +141,16 @@ class DefinableWorkflowStreamForm(AbstractEmailForm, AbstractStreamForm): FieldPanel('confirmation_text_extra'), ], heading="Confirmation email", - classname="collapsible collapsed" - ), + ) ] + edit_handler = TabbedInterface([ + ObjectList(content_panels, heading='Content'), + ObjectList(email_confirmation_panels, heading='Confirmation email'), + ObjectList(Page.promote_panels, heading='Promote'), + ObjectList(Page.settings_panels, heading='Settings', classname="settings"), + ]) + class FundType(DefinableWorkflowStreamForm): class Meta: diff --git a/opentech/apply/users/views.py b/opentech/apply/users/views.py index 0b7ad0a7b94e3ad5f0ed0620bf4b9318915207c1..dad852905dca7f74d2a48629156f5050b17d6762 100644 --- a/opentech/apply/users/views.py +++ b/opentech/apply/users/views.py @@ -34,44 +34,31 @@ def oauth(request): class ActivationView(TemplateView): - """ - Inspired by https://github.com/ubernostrum/django-registration - """ - def get(self, request, *args, **kwargs): - user = self.activate(*args, **kwargs) - if user: + user = self.get_user(kwargs.get('uidb64')) + + if self.valid(user, kwargs.get('token')): + user.is_active = True + user.save() + user.backend = 'django.contrib.auth.backends.ModelBackend' login(request, user) return redirect('users:activate_password') return render(request, 'users/activation/invalid.html') - def activate(self, *args, **kwargs): - user = self.validate_token(kwargs.get('uidb64'), kwargs.get('token')) - if user: - user.is_active = True - user.save() - return user - return False - def validate_token(self, uidb64, token): + def valid(self, user, token): """ - Verify that the activation key is valid and within the - permitted activation time window, returning the username if - valid or ``None`` if not. + Verify that the activation token is valid and within the + permitted activation time window. """ - uid = force_text(urlsafe_base64_decode(uidb64)) - user = self.get_user(uid) token_generator = PasswordResetTokenGenerator() + return user is not None and token_generator.check_token(user, token) - if user is not None and token_generator.check_token(user, token): - return user - - return False - def get_user(self, uid): + def get_user(self, uidb64): """ Given the verified uid, look up and return the corresponding user account if it exists, or ``None`` if it @@ -81,7 +68,7 @@ class ActivationView(TemplateView): try: user = User.objects.get(**{ - 'pk': uid, + 'pk': force_text(urlsafe_base64_decode(uidb64)), 'is_active': False }) return user @@ -93,8 +80,6 @@ def create_password(request): """ A custom view for the admin password change form used for account activation. """ - if request.user.is_active: - raise PermissionDenied if request.method == 'POST': form = AdminPasswordChangeForm(request.user, request.POST)