Projet

Général

Profil

0001-WIP-support-avatar-picture-in-user-profile-26022.patch

Paul Marillonnet, 04 septembre 2018 16:28

Télécharger (3,12 ko)

Voir les différences:

Subject: [PATCH] WIP support avatar picture in user profile (#26022)

 src/authentic2/attribute_kinds.py                    |  6 ++++++
 src/authentic2/custom_user/apps.py                   | 12 ++++++++++--
 .../templates/authentic2/accounts_edit.html          |  7 ++++++-
 3 files changed, 22 insertions(+), 3 deletions(-)
src/authentic2/attribute_kinds.py
151 151
        'field_class': PhoneNumberField,
152 152
        'rest_framework_field_class': PhoneNumberDRFField,
153 153
    },
154
    {
155
        'label': _('image'),
156
        'name': 'image',
157
        'field_class': forms.ImageField,
158
        'rest_framework_field_class': serializers.ImageField,
159
    },
154 160
]
155 161

  
156 162

  
src/authentic2/custom_user/apps.py
10 10
        from django.db.models.signals import post_migrate
11 11

  
12 12
        post_migrate.connect(
13
            self.create_first_name_last_name_attributes,
13
            self.create_custom_attributes,
14 14
            sender=self)
15 15

  
16
    def create_first_name_last_name_attributes(self, app_config, verbosity=2, interactive=True,
16
    def create_custom_attributes(self, app_config, verbosity=2, interactive=True,
17 17
                                               using=DEFAULT_DB_ALIAS, **kwargs):
18 18
        from django.utils import translation
19 19
        from django.utils.translation import ugettext_lazy as _
......
50 50
                      'asked_on_registration': True,
51 51
                      'user_editable': True,
52 52
                      'user_visible': True})
53
        attrs['avatar_picture'], created = Attribute.objects.get_or_create(
54
            name='avatar_picture',
55
            defaults={'kind': 'image',
56
                      'label': _('Avatar picture'),
57
                      'required': False,
58
                      'asked_on_registration': False,
59
                      'user_editable': True,
60
                      'user_visible': True})
53 61

  
54 62
        serialize = get_kind('string').get('serialize')
55 63
        for user in User.objects.all():
src/authentic2/templates/authentic2/accounts_edit.html
12 12
{% endblock %}
13 13

  
14 14
{% block content %}
15
  <form method="post">
15
    {% if form.is_multipart %}
16
      <form enctype="multipart/form-data" method="post">
17
    {% else %}
18
      <form method="post">
19
    {% endif %}
20

  
16 21
    {% csrf_token %}
17 22
    {{ form.as_p }}
18 23
    {% if form.instance and form.instance.id %}
19
-