Skip to content

Commit

Permalink
Merge pull request #542 from Muirrum/pronouns
Browse files Browse the repository at this point in the history
Pronouns
  • Loading branch information
tnurse18 committed Oct 8, 2021
2 parents c9891fd + d1bb519 commit 5f459ca
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
10 changes: 6 additions & 4 deletions accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, *args, **kwargs):
password = HTML("""<div class="col-lg-offset-2 col-lg-8">
<a href="{% url 'accounts:password' object.pk %}">Set a password for non-SSO login</a></div>""")
layout = [
Fieldset("User Info", 'first_name', 'last_name', 'username', 'email', 'nickname', password),
Fieldset("User Info", 'first_name', 'last_name', 'username', 'email', 'nickname', 'pronouns', password),
Fieldset("Contact Info", 'phone', 'carrier', Field('addr', rows=3)),
]
if request_user.is_lnl:
Expand Down Expand Up @@ -61,7 +61,7 @@ def clean_student_id(self):

class Meta:
model = get_user_model()
fields = ['username', 'email', 'first_name', 'last_name', 'nickname', 'groups', 'addr',
fields = ['username', 'email', 'first_name', 'last_name', 'nickname', 'pronouns', 'groups', 'addr',
'wpibox', 'mdc', 'phone', 'class_year', 'student_id', 'away_exp', 'carrier', 'title']

class FieldAccess:
Expand All @@ -70,11 +70,13 @@ def __init__(self):

thisisme = FieldAccessLevel(
lambda user, instance: (user == instance) and not user.locked,
enable=('email', 'first_name', 'last_name', 'addr', 'wpibox', 'phone', 'class_year', 'nickname', 'carrier')
enable=('email', 'first_name', 'last_name', 'addr', 'wpibox',
'phone', 'class_year', 'nickname', 'carrier', 'pronouns')
)
hasperm = FieldAccessLevel(
lambda user, instance: (user != instance) and user.has_perm('accounts.change_user', instance),
enable=('email', 'first_name', 'last_name', 'addr', 'wpibox', 'phone', 'class_year')
enable=('email', 'first_name', 'last_name', 'addr', 'wpibox',
'phone', 'class_year')
)
edit_groups = FieldAccessLevel(
lambda user, instance: user.has_perm('accounts.change_membership', instance),
Expand Down
18 changes: 18 additions & 0 deletions accounts/migrations/0006_user_pronouns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2021-09-20 00:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0005_remove_duplicate_perms'),
]

operations = [
migrations.AddField(
model_name='user',
name='pronouns',
field=models.CharField(blank=True, max_length=32, null=True, verbose_name='Pronouns'),
),
]
2 changes: 2 additions & 0 deletions accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def save(self, *args, **kwargs):
away_exp = DateField(verbose_name="Away Status Expiration", null=True, blank=True)
onboarded = BooleanField(default=False, verbose_name="Onboarding Complete")

pronouns = CharField(max_length=32, null=True, blank=True, verbose_name="Pronouns")

def __str__(self):
nick = '"%s" ' % self.nickname if self.nickname else ""
if self.first_name or self.last_name:
Expand Down
20 changes: 20 additions & 0 deletions docs/help/accounts/add-pronouns.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
===============================
Adding pronouns to your profile
===============================

LNLDB users can add their personal pronouns to their profiles.


Editing your profile
--------------------
Please see our other guide :doc:`Updating your profile <update-profile>` for
instructions on how to access the editing form.

Adding pronouns
---------------
Looking at the top section ("User Info"), if you scroll down to the bottom, you
will see a new field called "Pronouns". Add your pronouns in this field, then
scroll to the bottom and click the blue "Update Member and Return" button.

.. hint:
The pronouns field has a maximum of 32 characters
1 change: 1 addition & 0 deletions docs/help/user-guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Accounts
accounts/local-login
accounts/member-roles
accounts/linking-rt
accounts/add-pronouns

Events
^^^^^^
Expand Down
14 changes: 11 additions & 3 deletions site_tmpl/userdetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="jumbotron">
<div class="jumbotron" style="padding-bottom: 2%">
<h1> {{u}} </h1>
<h3>{{ u.groups.all|join:", " }}</h3>
<div class="pull-right">
<div class="row">
<div class="col-md-8 col-lg-9">
<h3>{{ u.groups.all|join:", " }}</h3>
{% if u.pronouns %}
<p><em>{{ u.pronouns }}</em></p>
{% endif %}
</div>
<div class="col-md-4 col-lg-3 text-right" style="margin-top:
2.5%">
{% if active == False %}
<a class="btn btn-danger btn-lg" href="" disabled>Account Disabled</a>
{% else %}
Expand All @@ -23,6 +30,7 @@ <h3>{{ u.groups.all|join:", " }}</h3>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% if pending_reports and request.user == u %}
Expand Down

0 comments on commit 5f459ca

Please sign in to comment.