Skip to content

Commit

Permalink
fix(dashboard): multiple requests matches avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeejoee committed Nov 19, 2023
1 parent af17de2 commit d586e2d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions fiesta/apps/accounts/forms/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _create_user_fields():
return fields


USER_FIELDS = _create_user_fields()
FORM_FIELDS_FROM_USER = _create_user_fields()


class UserProfileForm(BaseModelForm):
Expand Down Expand Up @@ -97,7 +97,7 @@ def callback(f: Field, **kwargs) -> FormField:
)

# include pre-generated field from User
locals().update(USER_FIELDS)
locals().update(FORM_FIELDS_FROM_USER)

class Meta:
model = UserProfile
Expand All @@ -108,7 +108,7 @@ class Meta:

# fields, which are shown independently on section configurations
fields = (
*USER_FIELDS.keys(),
*FORM_FIELDS_FROM_USER.keys(),
# TODO: think about limiting the choices by country of section, in which is current membership
"university",
"faculty",
Expand All @@ -134,14 +134,14 @@ def __init__(self, *args, **kwargs):
user = None

if user:
for f in USER_FIELDS:
for f in FORM_FIELDS_FROM_USER:
self.initial[f] = getattr(user, f, None)

def save(self, commit=True):
# first save user fields, since validation in UserProfile.save() could fail and we've to submit the form again
for f in USER_FIELDS:
for f in FORM_FIELDS_FROM_USER:
setattr(self.instance.user, f, self.cleaned_data.get(f))
self.instance.user.save(update_fields=USER_FIELDS.keys())
self.instance.user.save(update_fields=FORM_FIELDS_FROM_USER.keys())

return super().save(commit=commit)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
{% endif %}
{% endfor %}
{% if request_matches|length > 3 %}
<div class="avatar placeholder">
<a class="w-24 bg-neutral-focus text-neutral-content text-3xl flex justify-center items-center"
<div class="avatar placeholder hover:scale-105 transition-transform">
<a class="w-24 bg-base-300 text-base-content text-3xl flex justify-center items-center"
href="{% url "buddy_system:my-buddies" %}">
<span>+{{ request_matches|length|add:"-3" }}</span>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
{% endif %}
{% endfor %}
{% if request_matches|length > 3 %}
<div class="avatar placeholder">
<a class="w-24 bg-neutral-focus text-neutral-content text-3xl flex justify-center items-center"
<div class="avatar placeholder hover:scale-105 transition-transform">
<a class="w-24 bg-base-300 text-base-content text-3xl flex justify-center items-center"
href="{% url "pickup_system:my-pickups" %}">
<span>+{{ request_matches|length|add:"-3" }}</span>
</a>
Expand Down

0 comments on commit d586e2d

Please sign in to comment.