Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/remove-public-nav' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
frjo committed Jul 13, 2023
2 parents a19824a + a7341c3 commit 562f31f
Show file tree
Hide file tree
Showing 47 changed files with 479 additions and 598 deletions.
2 changes: 0 additions & 2 deletions docs/setup/deployment/stand-alone.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ BASIC_AUTH_PASSWORD: [PASS]
BASIC_AUTH_WHITELISTED_HTTP_HOSTS: www.example.org,apply.example.org
CLOUDFLARE_API_ZONEID: [KEY]
CLOUDFLARE_BEARER_TOKEN: [KEY]
MAILCHIMP_API_KEY: [KEY]-us10
MAILCHIMP_LIST_ID: [ID]
MAILGUN_API_KEY: [KEY]
SEND_READY_FOR_REVIEW: false
SLACK_DESTINATION_ROOM: #notify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ <h4 class="listing__title listing__title--link">
<span>{% trans "Next deadline" %}: {{ page.next_deadline|date:"M j, Y" }}</span>
</p>
{% endif %}
{% if details %}
{% comment %} {% if details %}
<a href="{% pageurl details %}">
{% endif %}
{% endif %} {% endcomment %}

{{ page.title }}

{% if details %}
{% comment %} {% if details %}
</a>
{% endif %}
{% endif %} {% endcomment %}
</h4>

{% if details.listing_summary or details.introduction %}
Expand Down
19 changes: 15 additions & 4 deletions hypha/apply/users/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
from django.contrib.auth.forms import AuthenticationForm
from django.utils.translation import gettext_lazy as _
from django_select2.forms import Select2Widget
from wagtail.models import Site
from wagtail.users.forms import UserCreationForm, UserEditForm

from .models import UserSettings
from .models import AuthSettings

User = get_user_model()


class CustomAuthenticationForm(AuthenticationForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.site = Site.find_for_request(self.request)
self.user_settings = UserSettings.for_site(site=self.site)
self.user_settings = AuthSettings.load(request_or_site=self.request)
self.extra_text = self.user_settings.extra_text
if self.user_settings.consent_show:
self.fields['consent'] = forms.BooleanField(
Expand Down Expand Up @@ -44,6 +42,19 @@ class CustomUserCreationForm(CustomUserAdminFormBase, UserCreationForm):
'password_mismatch': _("The two password fields didn't match."),
}

def __init__(self, request=None, *args, **kwargs):
self.request = request
super().__init__(*args, **kwargs)

self.user_settings = AuthSettings.load(request_or_site=self.request)
if self.user_settings.consent_show:
self.fields['consent'] = forms.BooleanField(
label=self.user_settings.consent_text,
help_text=self.user_settings.consent_help,
required=True,
)


class ProfileForm(forms.ModelForm):
class Meta:
model = User
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.19 on 2023-06-25 14:01

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0083_workflowcontenttype'),
('users', '0018_add_contracting_group'),
]

operations = [
migrations.RenameModel(
old_name='UserSettings',
new_name='AuthSettings',
),
]
37 changes: 37 additions & 0 deletions hypha/apply/users/migrations/0020_auto_20230625_1825.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 3.2.19 on 2023-06-25 18:25

from django.db import migrations, models
import wagtail.fields


class Migration(migrations.Migration):

dependencies = [
('users', '0019_rename_usersettings_authsettings'),
]

operations = [
migrations.AlterModelOptions(
name='authsettings',
options={'verbose_name': 'Auth Settings'},
),
migrations.RemoveField(
model_name='authsettings',
name='site',
),
migrations.AddField(
model_name='authsettings',
name='register_extra_text',
field=wagtail.fields.RichTextField(blank=True, help_text='Extra text to be displayed on register form'),
),
migrations.AlterField(
model_name='authsettings',
name='consent_show',
field=models.BooleanField(default=False, verbose_name='Show consent checkbox?'),
),
migrations.AlterField(
model_name='authsettings',
name='extra_text',
field=wagtail.fields.RichTextField(blank=True, help_text='Displayed along side login form', verbose_name='Login extra text'),
),
]
54 changes: 31 additions & 23 deletions hypha/apply/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtail.contrib.settings.models import BaseSiteSetting, register_setting
from wagtail.contrib.settings.models import BaseGenericSetting, register_setting
from wagtail.fields import RichTextField

from .groups import (
Expand Down Expand Up @@ -295,34 +295,42 @@ def __repr__(self):


@register_setting
class UserSettings(BaseSiteSetting):

class AuthSettings(BaseGenericSetting):
wagtail_reference_index_ignore = True

class Meta:
verbose_name = 'user settings'
verbose_name = 'Auth Settings'

consent_show = models.BooleanField(
'Show consent checkbox',
default=False,
consent_show = models.BooleanField(_('Show consent checkbox?'), default=False)
consent_text = models.CharField(max_length=255, blank=True)
consent_help = RichTextField(blank=True)
extra_text = RichTextField(
_("Login extra text"),
blank=True, help_text=_("Displayed along side login form")
)

consent_text = models.CharField(
max_length=255,
blank=True,
register_extra_text = RichTextField(
blank=True, help_text=_("Extra text to be displayed on register form")
)

consent_help = RichTextField(blank=True)

extra_text = RichTextField(blank=True)

panels = [
MultiFieldPanel([
FieldPanel('consent_show'),
FieldPanel('consent_text'),
FieldPanel('consent_help'),
], 'consent checkbox on login form'),
MultiFieldPanel([
FieldPanel('extra_text'),
], 'extra text on login form'),
MultiFieldPanel(
[
FieldPanel('consent_show'),
FieldPanel('consent_text'),
FieldPanel('consent_help'),
],
_("User consent on login & register forms")
),
MultiFieldPanel(
[
FieldPanel('extra_text'),
],
_('Login form customizations'),
),
MultiFieldPanel(
[
FieldPanel('register_extra_text'),
],
_('Register form customizations'),
),
]
11 changes: 6 additions & 5 deletions hypha/apply/users/templates/users/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
{% block title %}{% trans "Account" %}{% endblock %}

{% block content %}
<div class="admin-bar" xmlns="http://www.w3.org/1999/html">
<div class="admin-bar__inner admin-bar__inner--with-button">
<h3 class="admin-bar__heading">{% trans "Welcome" %} {{ user }}</h3>

{% adminbar %}
{% slot header %}{% trans "Welcome" %} {{ user }}{% endslot %}

<a href="{% url 'dashboard:dashboard' %}" class="button button--primary button--arrow-pixels-white" hx-boost='true'>
{% trans "Go to my dashboard" %}
<svg><use xlink:href="#arrow-head-pixels--solid"></use></svg>
</a>
</div>
</div>
{% endadminbar %}


<div class="profile">
<div class="profile__column">
Expand Down
20 changes: 14 additions & 6 deletions hypha/apply/users/templates/users/change_password.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
{% extends 'base.html' %}
{% extends "base-apply.html" %}
{% load i18n %}
{% block header_modifier %}header--light-bg{% endblock %}
{% block page_title %}{% trans "Set a password" %}{% endblock %}
{% block title %}{% trans "Set a password" %}{% endblock %}
{% block title %}{% trans "Update password" %}{% endblock %}

{% block content %}
<div class="wrapper wrapper--small wrapper--inner-space-medium">

{% adminbar %}
{% slot header %}{% trans "Change Password" %}{% endslot %}
{% slot back %}
<a class="simplified__submissions-link" href="{% url 'users:account' %}">
{% trans "Back to account" %}
</a>
{% endslot %}
{% endadminbar %}

<div class="wrapper mt-6 max-w-2xl">
<form class="form" action="" method="POST" novalidate>
{% if form.non_field_errors %}
<ul class="errorlist">
Expand All @@ -31,7 +39,7 @@
{% include "forms/includes/field.html" %}
{% endfor %}

<button class="button button--primary" type="submit">{% trans 'Reset password' %}</button>
<button class="button button--primary" type="submit">{% trans 'Submit' %}</button>
</form>
</div>
{% endblock %}
Loading

0 comments on commit 562f31f

Please sign in to comment.