Skip to content

Commit

Permalink
add an avatar license field
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Bähr committed Mar 5, 2024
1 parent 03a0802 commit 2edb5a0
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/pretalx/api/serializers/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, *args, **kwargs):

class Meta:
model = User
fields = ("code", "name", "biography", "avatar")
fields = ("code", "name", "biography", "avatar", "avatar_license")


class SubmitterOrgaSerializer(SubmitterSerializer):
Expand All @@ -34,6 +34,7 @@ class SpeakerSerializer(ModelSerializer):
code = CharField(source="user.code")
name = CharField(source="user.name")
avatar = SerializerMethodField()
avatar_license = SerializerMethodField()
submissions = SerializerMethodField()
answers = SerializerMethodField()

Expand Down Expand Up @@ -74,7 +75,7 @@ def get_answers(self, obj):

class Meta:
model = SpeakerProfile
fields = ("code", "name", "biography", "submissions", "avatar", "answers")
fields = ("code", "name", "biography", "submissions", "avatar", "avatar_license", "answers")


class SpeakerOrgaSerializer(SpeakerSerializer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <h2>{{ title }}</h2>
{% if form.avatar or form.get_gravatar %}
{% include "common/avatar.html" with user=user form=form %}
{% endif %}
{% if form.avatar_license %}{% bootstrap_field form.avatar_license layout='event' %}{% endif %}

{% bootstrap_field form.name layout='event' %}
{% if form.biography %}{% bootstrap_field form.biography layout='event' %}{% endif %}
Expand Down
1 change: 1 addition & 0 deletions src/pretalx/orga/forms/cfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(self, *args, obj, **kwargs):
"notes",
"biography",
"avatar",
"avatar_license",
"additional_speaker",
"availabilities",
"do_not_record",
Expand Down
6 changes: 6 additions & 0 deletions src/pretalx/orga/templates/orga/cfp/text.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@
<td></td>
<td></td>
</tr>
<tr>
<th>{% translate "Profile picture license" %}</th>
<td class="hide-label">{% bootstrap_field sform.cfp_ask_avatar_license layout='event-inline' %}</td>
<td></td>
<td></td>
</tr>
<tr>
<th>{% translate "Biography" %}</th>
<td class="hide-label">{% bootstrap_field sform.cfp_ask_biography layout='event-inline' %}</td>
Expand Down
1 change: 1 addition & 0 deletions src/pretalx/orga/templates/orga/speaker/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ <h5>
{% if form.avatar %}
{% include "common/avatar.html" with user=form.instance.user form=form %}
{% endif %}
{% if form.avatar_license %}{% bootstrap_field form.avatar_license layout='event' %}{% endif %}
{% bootstrap_field form.name layout='event' %}
{% bootstrap_field form.email layout='event' %}
<div class="d-flex mb-4">
Expand Down
2 changes: 1 addition & 1 deletion src/pretalx/person/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class SpeakerProfileForm(
RequestRequire,
forms.ModelForm,
):
USER_FIELDS = ["name", "email", "avatar", "get_gravatar"]
USER_FIELDS = ["name", "email", "avatar", "avatar_license", "get_gravatar"]
FIRST_TIME_EXCLUDE = ["email"]

def __init__(self, *args, name=None, **kwargs):
Expand Down
18 changes: 18 additions & 0 deletions src/pretalx/person/migrations/0028_user_avatar_license.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.10 on 2024-03-05 12:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("person", "0027_created_updated_everywhere"),
]

operations = [
migrations.AddField(
model_name="user",
name="avatar_license",
field=models.CharField(max_length=32, null=True),
),
]
6 changes: 6 additions & 0 deletions src/pretalx/person/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ class User(PermissionsMixin, GenerateCode, FileCleanupMixin, AbstractBaseUser):
"If you have registered with an email address that has a gravatar account, we can retrieve your profile picture from there."
),
)
avatar_license = models.CharField(
null=True,
blank=True,
max_length=32,
verbose_name=_("Profile Picture License")
)
pw_reset_token = models.CharField(
null=True, max_length=160, verbose_name="Password reset token"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def update_custom_domain(apps, schema_editor):
"availabilities",
"biography",
"avatar",
"avatar_license",
"notes",
"do_not_record",
"image",
Expand Down
1 change: 1 addition & 0 deletions src/pretalx/submission/models/cfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def default_fields():
"max_length": None,
},
"avatar": {"visibility": "optional"},
"avatar_license": {"visibility": "optional"},
"availabilities": {"visibility": "optional"},
"notes": {"visibility": "optional"},
"do_not_record": {"visibility": "optional"},
Expand Down

0 comments on commit 2edb5a0

Please sign in to comment.