Skip to content

Commit

Permalink
Merge pull request #68 from eMBee/issue-25
Browse files Browse the repository at this point in the history
Issue 25
  • Loading branch information
mariobehling authored Mar 6, 2024
2 parents 448aee6 + f964bff commit 364566d
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 5 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", "avatar_license")
fields = ("code", "name", "biography", "avatar", "avatar_source", "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_source = SerializerMethodField()
avatar_license = SerializerMethodField()
submissions = SerializerMethodField()
answers = SerializerMethodField()
Expand Down Expand Up @@ -75,7 +76,7 @@ def get_answers(self, obj):

class Meta:
model = SpeakerProfile
fields = ("code", "name", "biography", "submissions", "avatar", "avatar_license", "answers")
fields = ("code", "name", "biography", "submissions", "avatar", "avatar_source", "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_source %}{% bootstrap_field form.avatar_source layout='event' %}{% endif %}
{% if form.avatar_license %}{% bootstrap_field form.avatar_license layout='event' %}{% endif %}

{% bootstrap_field form.name layout='event' %}
Expand Down
2 changes: 2 additions & 0 deletions src/pretalx/cfp/templates/cfp/event/user_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ <h2>{% translate "Your Profile" %}</h2>
{% if request.event.cfp.request_avatar %}
{% include "common/avatar.html" with user=request.user form=profile_form %}
{% endif %}
{% if profile_form.avatar_source %}{% bootstrap_field profile_form.avatar_source layout='event' %}{% endif %}
{% if profile_form.avatar_license %}{% bootstrap_field profile_form.avatar_license layout='event' %}{% endif %}
{% bootstrap_field profile_form.name layout='event' %}
{% if profile_form.biography %}{% bootstrap_field profile_form.biography layout='event' %}{% endif %}
{% if profile_form.availabilities %}
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_source",
"avatar_license",
"additional_speaker",
"availabilities",
Expand Down
2 changes: 2 additions & 0 deletions src/pretalx/orga/forms/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def export_field_names(self):
return self.Meta.model_fields + [
"biography",
"avatar",
"avatar_source",
"avatar_license",
"submission_ids",
"submission_titles",
]
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 @@ -166,6 +166,12 @@
<td></td>
<td></td>
</tr>
<tr>
<th>{% translate "Profile picture source" %}</th>
<td class="hide-label">{% bootstrap_field sform.cfp_ask_avatar_source layout='event-inline' %}</td>
<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>
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_source %}{% bootstrap_field form.avatar_source layout='event' %}{% 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' %}
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", "avatar_license", "get_gravatar"]
USER_FIELDS = ["name", "email", "avatar", "avatar_source", "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/0029_alter_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 21:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("person", "0028_user_avatar_license"),
]

operations = [
migrations.AlterField(
model_name="user",
name="avatar_license",
field=models.TextField(null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.10 on 2024-03-06 13:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("person", "0029_alter_user_avatar_license"),
]

operations = [
migrations.AddField(
model_name="user",
name="avatar_source",
field=models.CharField(max_length=999, null=True),
),
migrations.AlterField(
model_name="user",
name="avatar_license",
field=models.CharField(max_length=999, null=True),
),
]
17 changes: 15 additions & 2 deletions src/pretalx/person/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pretalx.common.models import TIMEZONE_CHOICES
from pretalx.common.urls import build_absolute_uri
from pretalx.common.utils import path_with_hash
from pretalx.common.phrases import phrases


def avatar_path(instance, filename):
Expand Down Expand Up @@ -128,11 +129,23 @@ 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_source = models.CharField(
null=True,
blank=True,
max_length=999,
verbose_name=_("Profile Picture Source"),
help_text=_(
"Please enter the name of the author or source of image and a link if applicable."
),
)
avatar_license = models.CharField(
null=True,
blank=True,
max_length=32,
verbose_name=_("Profile Picture License")
max_length=999,
verbose_name=_("Profile Picture License"),
help_text=_(
"Please enter the name of the license of the photo and link to it if applicable."
),
)
pw_reset_token = models.CharField(
null=True, max_length=160, verbose_name="Password reset token"
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_source": {"visibility": "optional"},
"avatar_license": {"visibility": "optional"},
"availabilities": {"visibility": "optional"},
"notes": {"visibility": "optional"},
Expand Down

0 comments on commit 364566d

Please sign in to comment.