Skip to content

Commit

Permalink
Added support for release report financial steering committee page me…
Browse files Browse the repository at this point in the history
…mber images (#1605)
  • Loading branch information
daveoconnor committed Jan 22, 2025
1 parent 9c07e95 commit 6d718b8
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 4 deletions.
2 changes: 2 additions & 0 deletions libraries/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,9 @@ def get_stats(self):
).aggregate(lines=Sum("deletions"))["lines"]
# we want 2 channels per pdf page, use batched to get groups of 2
slack_stats = batched(self._get_slack_stats(prior_version, version), 2)
committee_members = version.financial_committee_members.all()
return {
"committee_members": committee_members,
"lines_added": lines_added,
"lines_removed": lines_removed,
"wordcloud_base64": self._generate_hyperkitty_word_cloud(version),
Expand Down
16 changes: 14 additions & 2 deletions templates/admin/release_report_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,20 @@ <h1 class="flex mb-0 font-bold">
<div class="pdf-page !p-16 {{ bg_color }}">
{% include "admin/_release_report_top_left_logo.html" %}
<h2>From the Fiscal Sponsorship Committee</h2>
<div class="w-full h-[80%] dynamic-text sponsor-message">
{{ version.sponsor_message|safe }}
<div class="flex flex-col w-full h-[80%] dynamic-text sponsor-message justify-between">
<div class="">{{ version.sponsor_message|safe }}</div>
<div class="committee_members border-t-1 flex flex-wrap mt-2 text-sm text-center">
{% for user in committee_members|dictsort:"first_name" %}
<figure class="w-32 m-2">
{% if user.hq_image %}
<img src="{{ user.hq_image_render.url }}" alt="{{ user.first_name }} {{ user.last_name }}" />
{% else %}
<img src="{% static 'img/Boost_Symbol_Transparent.svg' %}" alt="" />
{% endif %}
<figcaption class="p-1">{{user.first_name}} {{user.last_name}}</figcaption>
</figure>
{% endfor %}
</div>
</div>
</div>
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class EmailUserAdmin(UserAdmin):
)
},
),
(
_("High Quality Image"),
{"fields": ("hq_image",)},
),
)
add_fieldsets = (
(None, {"classes": ("wide",), "fields": ("email", "password1", "password2")}),
Expand Down
31 changes: 31 additions & 0 deletions users/migrations/0016_user_hq_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.2.16 on 2025-01-22 22:39

import core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("users", "0015_user_delete_permanently_at"),
]

operations = [
migrations.AddField(
model_name="user",
name="hq_image",
field=models.FileField(
blank=True,
help_text="A high-quality image of the user - used in profiles/reports.",
null=True,
upload_to="hiqh-quality-user-images",
validators=[
core.validators.FileTypeValidator(
extensions=[".jpg", ".jpeg", ".png"]
),
core.validators.MaxFileSizeValidator(max_size=52428800),
],
verbose_name="High Quality Image",
),
),
]
23 changes: 22 additions & 1 deletion users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFill

from core.validators import image_validator, max_file_size_validator
from core.validators import (
image_validator,
max_file_size_validator,
large_file_max_size_validator,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -221,6 +225,20 @@ class User(BaseUser):
format="JPEG",
options={"quality": 90},
)
hq_image = models.FileField(
upload_to="hiqh-quality-user-images",
help_text="A high-quality image of the user - used in profiles/reports.",
null=True,
blank=True,
validators=[image_validator, large_file_max_size_validator],
verbose_name="High Quality Image",
)
hq_image_render = ImageSpecField(
source="hq_image",
processors=[ResizeToFill(4096, 4096)],
format="JPEG",
options={"quality": 90},
)
claimed = models.BooleanField(
_("claimed"),
default=True,
Expand Down Expand Up @@ -318,6 +336,9 @@ def delete_account(self):
self.delete_permanently_at = None
self.save()

def __str__(self):
return f"{self.first_name} {self.last_name} <{self.email}>"


class LastSeen(models.Model):
"""
Expand Down
1 change: 1 addition & 0 deletions versions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class VersionAdmin(admin.ModelAdmin):
search_fields = ["name", "description"]
date_hierarchy = "release_date"
inlines = [VersionFileInline]
filter_horizontal = ["financial_committee_members"]
change_list_template = "admin/version_change_list.html"

def get_urls(self):
Expand Down
24 changes: 24 additions & 0 deletions versions/migrations/0018_version_financial_committee_members.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.16 on 2025-01-21 01:15

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("versions", "0017_alter_review_review_manager_alter_review_submitters"),
]

operations = [
migrations.AddField(
model_name="version",
name="financial_committee_members",
field=models.ManyToManyField(
blank=True,
help_text="Financial Committee members who are responsible for this release.",
to=settings.AUTH_USER_MODEL,
),
),
]
6 changes: 5 additions & 1 deletion versions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ class Version(models.Model):
blank=True,
help_text='Message to show in release reports on the "Fiscal Sponsorship Committee" page.', # noqa: E501
)

financial_committee_members = models.ManyToManyField(
User,
blank=True,
help_text="Financial Committee members who are responsible for this release.",
)
objects = VersionManager()

def __str__(self):
Expand Down

0 comments on commit 6d718b8

Please sign in to comment.