From 787ceab520e90242feaea0e86fee09c7d27030b0 Mon Sep 17 00:00:00 2001 From: Benjamin Graillot Date: Sat, 11 Aug 2018 03:58:03 +0200 Subject: [PATCH 1/4] [Adherent] Ajout gpg_fingerprint --- users/forms.py | 8 +++++++ users/migrations/0074_auto_20180810_2104.py | 22 +++++++++++++++++ users/migrations/0075_auto_20180811_0420.py | 26 +++++++++++++++++++++ users/models.py | 10 ++++++++ 4 files changed, 66 insertions(+) create mode 100644 users/migrations/0074_auto_20180810_2104.py create mode 100644 users/migrations/0075_auto_20180811_0420.py diff --git a/users/forms.py b/users/forms.py index b5859539..49135266 100644 --- a/users/forms.py +++ b/users/forms.py @@ -301,6 +301,7 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): super(AdherentForm, self).__init__(*args, prefix=prefix, **kwargs) self.fields['name'].label = 'Prénom' self.fields['surname'].label = 'Nom' + self.fields['email'].label = 'Adresse mail' self.fields['school'].label = 'Établissement' self.fields['comment'].label = 'Commentaire' self.fields['room'].label = 'Chambre' @@ -319,6 +320,7 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): 'room', 'shell', 'telephone', + 'gpg_fingerprint' ] def clean_telephone(self): @@ -331,6 +333,12 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): ) return telephone + def clean_gpg_fingerprint(self): + """Format the GPG fingerprint""" + gpg_fingerprint = self.cleaned_data.get('gpg_fingerprint', None) + if gpg_fingerprint: + return gpg_fingerprint.replace(' ', '').upper() + force = forms.BooleanField( label="Forcer le déménagement ?", initial=False, diff --git a/users/migrations/0074_auto_20180810_2104.py b/users/migrations/0074_auto_20180810_2104.py new file mode 100644 index 00000000..5ab77369 --- /dev/null +++ b/users/migrations/0074_auto_20180810_2104.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-08-10 19:04 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models +import users.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0073_auto_20180629_1614'), + ] + + operations = [ + migrations.AddField( + model_name='adherent', + name='gpg_fingerprint', + field=models.CharField(blank=True, max_length=40, null=True, validators=[django.core.validators.RegexValidator('^[0-9A-F]{40}$', message='Une fingerprint GPG doit contenit 40 caractères hexadécimaux')]), + ), + ] diff --git a/users/migrations/0075_auto_20180811_0420.py b/users/migrations/0075_auto_20180811_0420.py new file mode 100644 index 00000000..8ea2526f --- /dev/null +++ b/users/migrations/0075_auto_20180811_0420.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-08-11 02:20 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0074_auto_20180810_2104'), + ] + + operations = [ + migrations.AlterField( + model_name='adherent', + name='gpg_fingerprint', + field=models.CharField(blank=True, max_length=40, null=True, validators=[django.core.validators.RegexValidator('^[0-9A-F]{40}$', message='Une fingerprint GPG doit contenir 40 caractères hexadécimaux')]), + ), + migrations.AlterField( + model_name='user', + name='email', + field=models.EmailField(max_length=254, unique=True), + ), + ] diff --git a/users/models.py b/users/models.py index 66bff7c6..01de431c 100755 --- a/users/models.py +++ b/users/models.py @@ -985,6 +985,16 @@ class Adherent(User): blank=True, null=True ) + gpg_fingerprint = models.CharField( + max_length=40, + blank=True, + null=True, + validators=[RegexValidator( + '^[0-9A-F]{40}$', + message="Une fingerprint GPG doit contenir 40 " + "caractères hexadécimaux" + )] + ) @classmethod def get_instance(cls, adherentid, *_args, **_kwargs): From a5870aacce903f4c65b221e4cf0024593827fbdc Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Sat, 11 Aug 2018 04:22:14 +0200 Subject: [PATCH 2/4] gpg fpr display --- users/templates/users/profil.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index d5b4ad4b..84d23009 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -239,6 +239,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endif %} + {% if users.adherent.gpg_fingerprint %} + Empreinte GPG + {{ users.gpg_fingerprint }} + {% endif %} + + {% if users.shell %} Shell {{ users.shell }} From 7deb99f8838ed27d55cea8471962b43202eb9864 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Tue, 14 Aug 2018 10:10:53 +0200 Subject: [PATCH 3/4] Fix les migrations --- users/migrations/0074_auto_20180810_2104.py | 2 +- users/migrations/0075_auto_20180811_0420.py | 26 --------------------- 2 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 users/migrations/0075_auto_20180811_0420.py diff --git a/users/migrations/0074_auto_20180810_2104.py b/users/migrations/0074_auto_20180810_2104.py index 5ab77369..bc32a266 100644 --- a/users/migrations/0074_auto_20180810_2104.py +++ b/users/migrations/0074_auto_20180810_2104.py @@ -17,6 +17,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='adherent', name='gpg_fingerprint', - field=models.CharField(blank=True, max_length=40, null=True, validators=[django.core.validators.RegexValidator('^[0-9A-F]{40}$', message='Une fingerprint GPG doit contenit 40 caractères hexadécimaux')]), + field=models.CharField(blank=True, max_length=40, null=True, validators=[django.core.validators.RegexValidator('^[0-9A-F]{40}$', message='Une fingerprint GPG doit contenir 40 caractères hexadécimaux')]), ), ] diff --git a/users/migrations/0075_auto_20180811_0420.py b/users/migrations/0075_auto_20180811_0420.py deleted file mode 100644 index 8ea2526f..00000000 --- a/users/migrations/0075_auto_20180811_0420.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.7 on 2018-08-11 02:20 -from __future__ import unicode_literals - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0074_auto_20180810_2104'), - ] - - operations = [ - migrations.AlterField( - model_name='adherent', - name='gpg_fingerprint', - field=models.CharField(blank=True, max_length=40, null=True, validators=[django.core.validators.RegexValidator('^[0-9A-F]{40}$', message='Une fingerprint GPG doit contenir 40 caractères hexadécimaux')]), - ), - migrations.AlterField( - model_name='user', - name='email', - field=models.EmailField(max_length=254, unique=True), - ), - ] From b73ccdd0430f4ce0e3cbfb688ff8b9ed217ae0c3 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Tue, 14 Aug 2018 10:11:53 +0200 Subject: [PATCH 4/4] Affiche la fingerpring PGP correctement. --- users/templates/users/profil.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index 84d23009..c2053612 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -51,7 +51,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% elif not users.is_adherent %} + @@ -241,7 +241,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if users.adherent.gpg_fingerprint %} Empreinte GPG - {{ users.gpg_fingerprint }} + {{ users.adherent.gpg_fingerprint }} {% endif %}