Skip to content

Commit 081a25d

Browse files
Merge branch 'pyladies:main' into add-cancel-button-to-logout
2 parents 76ee331 + 131c518 commit 081a25d

File tree

11 files changed

+235
-27
lines changed

11 files changed

+235
-27
lines changed

portal_account/views.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ def get_form_kwargs(self):
3434
kwargs.update({"user": self.request.user})
3535
return kwargs
3636

37-
3837
class PortalProfileUpdate(UpdateView):
3938
model = PortalProfile
40-
fields = "__all__"
39+
template_name = "portal_account/portalprofile_form.html"
4140
success_url = reverse_lazy("index")
41+
form_class = PortalProfileForm
42+
43+
def get_form_kwargs(self):
44+
kwargs = super(PortalProfileUpdate, self).get_form_kwargs()
45+
kwargs.update({"user": self.request.user})
46+
return kwargs

templates/portal/base.html

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
</div>
8686
</div>
8787
</nav>
88+
<div class="alert alert-info" role="alert">
89+
<strong>Development Notice:</strong> The codebase is real, but the database is not. Any signups, accounts, or data entered on this site may be deleted without notice. For now, feel free to play around.
90+
</div>
8891
<div class="container my-5">
8992
{% block content %}
9093
{% endblock %}

templates/portal_account/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ <h1 class="display-5">Account Management</h1>
1313
<hr>
1414
<h1 class="display-5">Your Portal Profile</h1>
1515
{% if profile_id %}
16-
<a class="btn btn-primary btn-lg" role="button" href="{% url 'portal_account:portal_profile_detail' profile_id%}">View my profile</a>
16+
<a class="btn btn-primary btn-lg" role="button" href="{% url 'portal_account:portal_profile_detail' profile_id %}">View my profile</a>
17+
<a class="btn btn-secondary btn-lg" role="button" href="{% url 'portal_account:portal_profile_edit' profile_id %}">Edit profile</a>
1718
{% else %}
1819
<p class="col-md-8 fs-4">
1920
Your profile is not complete. Please complete your profile before proceeding.

templates/portal_account/portalprofile_detail.html

+33-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,38 @@
55
{% block body %}
66
{% endblock %}
77
{% block content %}
8-
<h1>Your Profile</h1>
9-
<div>
10-
{% bootstrap_label object.user.username %}
8+
<h1 class="display-5 mb-4">Your Portal Profile</h1>
9+
10+
<div class="card mb-4">
11+
<div class="card-header">
12+
<h5 class="card-title mb-0">Basic Information</h5>
13+
</div>
14+
<div class="card-body">
15+
<div class="row mb-3">
16+
<div class="col-md-3 fw-bold">Username:</div>
17+
<div class="col-md-9">{{ object.user.username }}</div>
18+
</div>
19+
<div class="row mb-3">
20+
<div class="col-md-3 fw-bold">Name:</div>
21+
<div class="col-md-9">{{ object.user.first_name }} {{ object.user.last_name }}</div>
22+
</div>
23+
<div class="row mb-3">
24+
<div class="col-md-3 fw-bold">Email:</div>
25+
<div class="col-md-9">{{ object.user.email }}</div>
26+
</div>
27+
<div class="row mb-3">
28+
<div class="col-md-3 fw-bold">Pronouns:</div>
29+
<div class="col-md-9">{{ object.pronouns|default:"Not specified" }}</div>
30+
</div>
31+
<div class="row mb-3">
32+
<div class="col-md-3 fw-bold">Code of Conduct Agreement:</div>
33+
<div class="col-md-9">{% if object.coc_agreement %}Agreed{% else %}Not agreed{% endif %}</div>
34+
</div>
35+
</div>
36+
</div>
37+
38+
<div class="mt-4">
39+
<a class="btn btn-primary" href="{% url 'portal_account:portal_profile_edit' object.pk %}">Edit Profile</a>
40+
<a class="btn btn-secondary" href="{% url 'portal_account:index' %}">Back to Account Management</a>
1141
</div>
12-
{% bootstrap_label object.user.first_name %}
13-
{% bootstrap_label object.user.last_name %}
14-
1542
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% extends "portal/base.html" %}
2+
{% load allauth i18n %}
3+
{% load django_bootstrap5 %}
4+
5+
{% block body %}
6+
{% endblock %}
7+
{% block content %}
8+
<main>
9+
<h1 class="display-5">Edit your Portal Profile</h1>
10+
<p class="lead">
11+
Update your portal profile information below.
12+
</p>
13+
<div class="row g-5">
14+
{% bootstrap_form_errors form %}
15+
<form action="{% url 'portal_account:portal_profile_edit' object.pk %}" method="post" class="form">{% csrf_token %}
16+
{% bootstrap_field form.username %}
17+
{% bootstrap_field form.first_name %}
18+
{% bootstrap_field form.last_name %}
19+
{% bootstrap_field form.email %}
20+
{% bootstrap_field form.pronouns %}
21+
{% bootstrap_field form.coc_agreement %}
22+
<div class="mt-4">
23+
<input type="submit" value="Update Profile" class="btn btn-primary" />
24+
<a href="{% url 'portal_account:portal_profile_detail' object.pk %}" class="btn btn-secondary">Cancel</a>
25+
</div>
26+
</form>
27+
</div>
28+
</main>
29+
{% endblock %}

templates/portal_account/portalprofile_form.html

+11-4
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,27 @@
66
{% endblock %}
77
{% block content %}
88
<main>
9-
<h1 class="display-5">Create your Portal Profile</h1>
9+
<h1 class="display-5">{% if object.pk %}Edit{% else %}Create{% endif %} your Portal Profile</h1>
1010
<p class="lead">
11-
Please complete your portal profile before proceeding.
11+
{% if object.pk %}Update your portal profile information below.{% else %}Please complete your portal profile before proceeding.{% endif %}
1212
</p>
1313
<div class="row g-5">
1414
{% bootstrap_form_errors form %}
15-
<form action="{% url 'portal_account:portal_profile_new' %}" method="post" class="form">{% csrf_token %}
15+
<form action="{% if object.pk %}{% url 'portal_account:portal_profile_edit' object.pk %}{% else %}{% url 'portal_account:portal_profile_new' %}{% endif %}" method="post" class="form">{% csrf_token %}
1616
{% bootstrap_field form.username %}
1717
{% bootstrap_field form.first_name %}
1818
{% bootstrap_field form.last_name %}
1919
{% bootstrap_field form.email %}
2020
{% bootstrap_field form.pronouns %}
2121
{% bootstrap_field form.coc_agreement %}
22-
<input type="submit" value="Submit" />
22+
<div class="mt-4">
23+
<input type="submit" value="{% if object.pk %}Update Profile{% else %}Create Profile{% endif %}" class="btn btn-primary" />
24+
{% if object.pk %}
25+
<a href="{% url 'portal_account:portal_profile_detail' object.pk %}" class="btn btn-secondary">Cancel</a>
26+
{% else %}
27+
<a href="{% url 'portal_account:index' %}" class="btn btn-secondary">Cancel</a>
28+
{% endif %}
29+
</div>
2330
</form>
2431
{# <form class="needs-validation" novalidate="">#}
2532
{# <div class="row g-3">#}

templates/volunteer/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
{% block content %}
88
<h1 class="display-5">Volunteer Profile</h1>
99
{% if profile_id %}
10-
<a class="btn btn-primary btn-lg" role="button" href="{% url 'volunteer:volunteer_profile_detail' profile_id%}">View my Profile</a>
10+
<a class="btn btn-primary btn-lg" role="button" href="{% url 'volunteer:volunteer_profile_detail' profile_id %}">View my Profile</a>
11+
<a class="btn btn-secondary btn-lg" role="button" href="{% url 'volunteer:volunteer_profile_edit' profile_id %}">Edit Profile</a>
1112
{% else %}
1213
<p class="col-md-8 fs-4">
1314
You have not created your Volunteer Profile yet. Once you created your profile, our team will review it.

templates/volunteer/volunteerprofile_detail.html

+135-10
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,142 @@
55
{% block body %}
66
{% endblock %}
77
{% block content %}
8-
<h1>Your Profile</h1>
9-
<div>
10-
{% bootstrap_label object.timezone %}
8+
<h1 class="display-5 mb-4">Your Volunteer Profile</h1>
9+
10+
<div class="card mb-4">
11+
<div class="card-header">
12+
<h5 class="card-title mb-0">Basic Information</h5>
13+
</div>
14+
<div class="card-body">
15+
<div class="row mb-3">
16+
<div class="col-md-3 fw-bold">Username:</div>
17+
<div class="col-md-9">{{ object.user.username }}</div>
18+
</div>
19+
<div class="row mb-3">
20+
<div class="col-md-3 fw-bold">Name:</div>
21+
<div class="col-md-9">{{ object.user.first_name }} {{ object.user.last_name }}</div>
22+
</div>
23+
<div class="row mb-3">
24+
<div class="col-md-3 fw-bold">Email:</div>
25+
<div class="col-md-9">{{ object.user.email }}</div>
26+
</div>
27+
<div class="row mb-3">
28+
<div class="col-md-3 fw-bold">Timezone:</div>
29+
<div class="col-md-9">{{ object.timezone }}</div>
30+
</div>
31+
<div class="row mb-3">
32+
<div class="col-md-3 fw-bold">PyLadies Chapter:</div>
33+
<div class="col-md-9">{{ object.pyladies_chapter|default:"Not specified" }}</div>
34+
</div>
35+
<div class="row mb-3">
36+
<div class="col-md-3 fw-bold">Application Status:</div>
37+
<div class="col-md-9">{{ object.application_status }}</div>
38+
</div>
39+
<div class="row mb-3">
40+
<div class="col-md-3 fw-bold">Languages:</div>
41+
<div class="col-md-9">
42+
{% for language in object.languages_spoken %}
43+
<span class="badge bg-info text-dark me-1">{{ language }}</span>
44+
{% endfor %}
45+
</div>
46+
</div>
47+
</div>
1148
</div>
12-
{% bootstrap_label object.github_username %}
13-
{% bootstrap_label object.instagram_username %}
14-
{% bootstrap_label object.discord_username %}
15-
<div>
16-
{% bootstrap_label object.status %}
49+
50+
<div class="card mb-4">
51+
<div class="card-header">
52+
<h5 class="card-title mb-0">Teams & Roles</h5>
53+
</div>
54+
<div class="card-body">
55+
<div class="row mb-3">
56+
<div class="col-md-3 fw-bold">Teams:</div>
57+
<div class="col-md-9">
58+
{% if object.teams.all %}
59+
{% for team in object.teams.all %}
60+
<span class="badge bg-primary me-1">{{ team.short_name }}</span>
61+
{% endfor %}
62+
{% else %}
63+
Not assigned to any teams yet
64+
{% endif %}
65+
</div>
66+
</div>
67+
<div class="row mb-3">
68+
<div class="col-md-3 fw-bold">Roles:</div>
69+
<div class="col-md-9">
70+
{% if object.roles.all %}
71+
{% for role in object.roles.all %}
72+
<span class="badge bg-secondary me-1">{{ role.short_name }}</span>
73+
{% endfor %}
74+
{% else %}
75+
No roles assigned yet
76+
{% endif %}
77+
</div>
78+
</div>
79+
</div>
1780
</div>
18-
<div>
19-
{% bootstrap_label object.pyladies_chapter %}
81+
82+
<div class="card mb-4">
83+
<div class="card-header">
84+
<h5 class="card-title mb-0">Social Media</h5>
85+
</div>
86+
<div class="card-body">
87+
{% if object.github_username or object.discord_username or object.instagram_username or object.bluesky_username or object.mastodon_url or object.x_username or object.linkedin_url %}
88+
{% if object.github_username %}
89+
<div class="row mb-2">
90+
<div class="col-md-3 fw-bold">GitHub:</div>
91+
<div class="col-md-9">{{ object.github_username }}</div>
92+
</div>
93+
{% endif %}
94+
95+
{% if object.discord_username %}
96+
<div class="row mb-2">
97+
<div class="col-md-3 fw-bold">Discord:</div>
98+
<div class="col-md-9">{{ object.discord_username }}</div>
99+
</div>
100+
{% endif %}
101+
102+
{% if object.instagram_username %}
103+
<div class="row mb-2">
104+
<div class="col-md-3 fw-bold">Instagram:</div>
105+
<div class="col-md-9">{{ object.instagram_username }}</div>
106+
</div>
107+
{% endif %}
108+
109+
{% if object.bluesky_username %}
110+
<div class="row mb-2">
111+
<div class="col-md-3 fw-bold">Bluesky:</div>
112+
<div class="col-md-9">{{ object.bluesky_username }}</div>
113+
</div>
114+
{% endif %}
115+
116+
{% if object.mastodon_url %}
117+
<div class="row mb-2">
118+
<div class="col-md-3 fw-bold">Mastodon:</div>
119+
<div class="col-md-9">{{ object.mastodon_url }}</div>
120+
</div>
121+
{% endif %}
122+
123+
{% if object.x_username %}
124+
<div class="row mb-2">
125+
<div class="col-md-3 fw-bold">X/Twitter:</div>
126+
<div class="col-md-9">{{ object.x_username }}</div>
127+
</div>
128+
{% endif %}
129+
130+
{% if object.linkedin_url %}
131+
<div class="row mb-2">
132+
<div class="col-md-3 fw-bold">LinkedIn:</div>
133+
<div class="col-md-9">{{ object.linkedin_url }}</div>
134+
</div>
135+
{% endif %}
136+
{% else %}
137+
<p>No social media profiles added</p>
138+
{% endif %}
139+
</div>
140+
</div>
141+
142+
<div class="mt-4">
143+
<a class="btn btn-primary" href="{% url 'volunteer:volunteer_profile_edit' object.pk %}">Edit Profile</a>
144+
<a class="btn btn-secondary" href="{% url 'volunteer:index' %}">Back to Volunteer Dashboard</a>
20145
</div>
21146
{% endblock %}

templates/volunteer/volunteerprofile_form.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
<main>
99
<h1 class="display-5">Create your Volunteer Profile</h1>
1010
<p class="lead">
11+
{% if object.pk %}Update your information below.{% else %}Fill in the profile below.{% endif %}
1112
Fill in the profile below.
1213
</p>
1314
<div class="row g-5">
1415
{% bootstrap_form_errors form %}
15-
<form action="{% url 'volunteer:volunteer_profile_new' %}" method="post" class="form">{% csrf_token %}
16+
<form action="{% if object.pk %}{% url 'volunteer:volunteer_profile_edit' object.pk %}{% else %}{% url 'volunteer:volunteer_profile_new' %}{% endif %}" method="post" class="form">{% csrf_token %}
1617
{% bootstrap_field form.languages_spoken %}
1718
{% bootstrap_field form.teams %}
1819
{% bootstrap_field form.pyladies_chapter %}
@@ -24,7 +25,7 @@ <h1 class="display-5">Create your Volunteer Profile</h1>
2425
{% bootstrap_field form.mastodon_url %}
2526
{% bootstrap_field form.x_username %}
2627
{% bootstrap_field form.linkedin_url %}
27-
<input type="submit" value="Submit" />
28+
<input type="submit" value="{% if object.pk %}Update Profile{% else %}Create Profile{% endif %}" class="btn btn-primary" />
2829
</form>
2930
</div>
3031
</main>

volunteer/forms.py

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def __init__(self, *args, **kwargs):
1616
self.user = kwargs.pop("user", None)
1717
super().__init__(*args, **kwargs)
1818

19+
if self.instance and self.instance.pk:
20+
pass
21+
1922
def save(self, commit=True):
2023
""" """
2124
user = self.user

volunteer/views.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ def get_form_kwargs(self):
4141

4242
class VolunteerProfileUpdate(UpdateView):
4343
model = VolunteerProfile
44-
fields = "__all__"
44+
template_name = "volunteer/volunteerprofile_form.html"
4545
success_url = reverse_lazy("volunteer:index")
46+
form_class = VolunteerProfileForm
47+
48+
def get_form_kwargs(self):
49+
kwargs = super(VolunteerProfileUpdate, self).get_form_kwargs()
50+
kwargs.update({"user": self.request.user})
51+
return kwargs
4652

4753

4854
class VolunteerProfileDelete(DeleteView):

0 commit comments

Comments
 (0)