From 8118b37805273d80e7b57ab129ce631c22fb7278 Mon Sep 17 00:00:00 2001 From: Augustin Laville Date: Sat, 15 Apr 2017 21:12:53 +0200 Subject: [PATCH 01/75] =?UTF-8?q?Update=20factory-boy:=202.7.0=20=E2=86=92?= =?UTF-8?q?=202.8.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ce4931b63a..0c2241642d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ django-model-utils==2.6.1 django-munin==0.2.2 python-memcached==1.58 lxml==3.7.3 -factory-boy==2.7.0 +factory-boy==2.8.1 pygeoip==0.3.2 pillow==4.1.0 gitpython==1.0.1 From 05b4160da13d37a1c7d73a225e4929096fe13292 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Wed, 26 Apr 2017 19:44:41 +0200 Subject: [PATCH 02/75] Configure Matrix webhook for travis --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 98c553aa2c..093d09f1f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,10 +27,12 @@ env: - TEST_APP="-e front" notifications: - irc: - channels: - - irc.smoothirc.net#zds-dev - skip_join: true + webhooks: + urls: + - "https://scalar.vector.im/api/neb/services/hooks/dHJhdmlzLWNpLyU0MHNhbmRob3NlJTNBc2FuZGhvc2UuZnIvJTIxd2dlbkt2dHpNY3NYREtiZEhZJTNBbWF0cml4Lm9yZw" + on_success: change + on_failure: always + on_start: never services: - memcached From 9317fcb4c395ee2bc70a5b3d56413a92a11d0b21 Mon Sep 17 00:00:00 2001 From: Michael Marx Date: Tue, 2 May 2017 20:34:46 +0200 Subject: [PATCH 03/75] Ajoute d'un compteur de commentaires pour les billets (#4328) --- templates/home.html | 2 +- templates/tutorialv2/index_online.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/home.html b/templates/home.html index 3929bd55e0..11598cbe47 100644 --- a/templates/home.html +++ b/templates/home.html @@ -170,7 +170,7 @@

{% for opinion in last_opinions %} - {% include 'tutorialv2/includes/content_item.part.html' with public_content=opinion show_description=True item_class=forloop.first|yesno:", mini" ignore_date=True %} + {% include 'tutorialv2/includes/content_item.part.html' with public_content=opinion show_description=True item_class=forloop.first|yesno:", mini" ignore_date=True show_reactions=True %} {% empty %}

{% trans "Aucun billet disponible." %}

{% endfor %} diff --git a/templates/tutorialv2/index_online.html b/templates/tutorialv2/index_online.html index 7969023b6f..c03c653ddd 100644 --- a/templates/tutorialv2/index_online.html +++ b/templates/tutorialv2/index_online.html @@ -67,7 +67,7 @@

- {% if current_content_type == "ARTICLE" %} + {% if current_content_type == "ARTICLE" or current_content_type == "OPINION" %} {% for public_content in public_contents %} {% include "tutorialv2/includes/content_item.part.html" with public_content=public_content show_description=True show_reactions=True %} {% endfor %} From dcd451fc48b570547ad7e083b673344ecd106a3c Mon Sep 17 00:00:00 2001 From: Victor Felder Date: Tue, 2 May 2017 21:37:44 +0200 Subject: [PATCH 04/75] Corrige le plugin munin --- zds/munin/views.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/zds/munin/views.py b/zds/munin/views.py index 34e106b693..c06d8fe2e9 100644 --- a/zds/munin/views.py +++ b/zds/munin/views.py @@ -53,11 +53,9 @@ def total_articles(request): draft.label Draft draft.draw LINE1 featured.label Featured -featured.draw STACK published.label Published -published.draw STACK converted.label Converted -converted.draw STACK""") +""") def total_opinions(request): opinions = PublishableContent.objects.filter(type='OPINION').all() return [('draft', opinions.filter(sha_public__isnull=True).count()), From 6ebfa431aeb894a83959e8c041511607b825ad76 Mon Sep 17 00:00:00 2001 From: Victor Felder Date: Tue, 2 May 2017 21:37:52 +0200 Subject: [PATCH 05/75] Corrige la doc de MEP --- update.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/update.md b/update.md index c825391cb1..f2b0cf89ff 100644 --- a/update.md +++ b/update.md @@ -1016,10 +1016,12 @@ Tribunes ``` [zds_total_tribunes] - env.url http://www.zestedesavoir.com/munin/total_tribunes/ + env.url https://zestedesavoir.com/munin/total_opinions/ env.graph_category zds ``` ++ Créer le symlink nécessaire dans `/etc/munin/plugins` (`ln -s /usr/share/munin/plugins/django.py zds_total_tribunes`) + + Réindexer les données (un champ a été rajouté): ``` From 953ad839dc08bcdc6b9a3a80508986bab0220cc9 Mon Sep 17 00:00:00 2001 From: Victor Felder Date: Tue, 2 May 2017 21:40:08 +0200 Subject: [PATCH 06/75] Sync config prod -> doc --- doc/source/install/configs/munin/zds.conf | 24 ++++++++++++--------- doc/source/install/configs/settings_prod.py | 18 ++++++++++------ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/doc/source/install/configs/munin/zds.conf b/doc/source/install/configs/munin/zds.conf index 4cb29c9e79..2a8502a370 100755 --- a/doc/source/install/configs/munin/zds.conf +++ b/doc/source/install/configs/munin/zds.conf @@ -1,40 +1,44 @@ [zds_db_performance] -env.url http://gandi.zestedesavoir.com/munin/db_performance/ +env.url https://zestedesavoir.com/munin/db_performance/ env.graph_category zds [zds_total_users] -env.url http://gandi.zestedesavoir.com/munin/total_users/ +env.url https://zestedesavoir.com/munin/total_users/ env.graph_category zds [zds_active_users] -env.url http://gandi.zestedesavoir.com/munin/active_users/ +env.url https://zestedesavoir.com/munin/active_users/ env.graph_category zds [zds_total_sessions] -env.url http://gandi.zestedesavoir.com/munin/total_sessions/ +env.url https://zestedesavoir.com/munin/total_sessions/ env.graph_category zds [zds_active_sessions] -env.url http://gandi.zestedesavoir.com/munin/active_sessions/ +env.url https://zestedesavoir.com/munin/active_sessions/ env.graph_category zds [zds_total_topics] -env.url http://gandi.zestedesavoir.com/munin/total_topics/ +env.url https://zestedesavoir.com/munin/total_topics/ env.graph_category zds [zds_total_posts] -env.url http://gandi.zestedesavoir.com/munin/total_posts/ +env.url https://zestedesavoir.com/munin/total_posts/ env.graph_category zds [zds_total_mps] -env.url http://gandi.zestedesavoir.com/munin/total_mps/ +env.url https://zestedesavoir.com/munin/total_mps/ env.graph_category zds [zds_total_tutorials] -env.url http://gandi.zestedesavoir.com/munin/total_tutorials/ +env.url https://zestedesavoir.com/munin/total_tutorials/ env.graph_category zds [zds_total_articles] -env.url http://gandi.zestedesavoir.com/munin/total_articles/ +env.url https://zestedesavoir.com/munin/total_articles/ +env.graph_category zds + +[zds_total_tribunes] +env.url https://zestedesavoir.com/munin/total_opinions/ env.graph_category zds diff --git a/doc/source/install/configs/settings_prod.py b/doc/source/install/configs/settings_prod.py index 031b70a274..a908761c12 100644 --- a/doc/source/install/configs/settings_prod.py +++ b/doc/source/install/configs/settings_prod.py @@ -5,10 +5,13 @@ import os +from raven import Client +from zds.utils.context_processor import get_git_version + from settings import ABSOLUTE_URL_OVERRIDES, AUTHENTICATION_BACKENDS, BASE_DIR from settings import CORS_ALLOW_HEADERS, CORS_ALLOW_METHODS, CORS_EXPOSE_HEADERS from settings import CORS_ORIGIN_ALLOW_ALL, CRISPY_TEMPLATE_PACK, FILE_UPLOAD_HANDLERS -from settings import GEOIP_PATH, HAYSTACK_CONNECTIONS, HAYSTACK_CUSTOM_HIGHLIGHTER +from settings import GEOIP_PATH from settings import INSTALLED_APPS, LANGUAGES, LANGUAGE_CODE, LOCALE_PATHS from settings import LOGIN_REDIRECT_URL, LOGIN_URL, MEDIA_URL, MESSAGE_TAGS from settings import MIDDLEWARE_CLASSES, OAUTH2_PROVIDER, REST_FRAMEWORK @@ -16,6 +19,7 @@ from settings import STATICFILES_DIRS, STATICFILES_FINDERS, STATIC_URL, SWAGGER_SETTINGS from settings import THUMBNAIL_ALIASES, THUMBNAIL_PRESERVE_EXTENSIONS, THUMBNAIL_QUALITY from settings import TIME_ZONE, USE_I18N, USE_TZ, WSGI_APPLICATION, ZDS_APP +from settings import ES_ENABLED, ES_CONNECTIONS, ES_SEARCH_INDEX ##### Django settings ##### @@ -102,9 +106,7 @@ 'django.contrib.messages.context_processors.messages', 'social.apps.django_app.context_processors.backends', 'social.apps.django_app.context_processors.login_redirect', - # ZDS context processors - 'zds.member.utils.ZDSCustomizeSocialAuthExceptionMiddleware', 'zds.utils.context_processor.app_settings', 'zds.utils.context_processor.git_version', ], @@ -117,6 +119,7 @@ # https://docs.getsentry.com/hosted/clients/python/integrations/django/ RAVEN_CONFIG = { 'dsn': 'to-fill' + 'release': get_git_version()['name'], } LOGGING = { @@ -248,7 +251,7 @@ ZDS_APP['site']['secure_url'] = 'https://zestedesavoir.com' # added in v21 -ZDS_APP['display_search_bar'] = False +ZDS_APP['display_search_bar'] = True # forum ZDS_APP['forum']['beta_forum_id'] = 23 @@ -272,6 +275,9 @@ ZDS_APP['content']['repo_public_path'] = '/opt/zds/data/contents-public' ZDS_APP['content']['extra_content_generation_policy'] = 'WATCHDOG' +# enable ping! +ZDS_APP['comment']['enable_pings'] = False + # Vote anonymisation - cf v18 : https://goo.gl/L6X4hw VOTES_ID_LIMIT = 131319 @@ -285,10 +291,8 @@ FORCE_HTTPS_FOR_MEMBERS = True ENABLE_HTTPS_DECORATOR = True -# for social auth exception to be properly handled -SOCIAL_AUTH_RAISE_EXCEPTIONS = False - # visual changes #ZDS_APP['visual_changes'] = ['snow', 'clem-christmas'] #ZDS_APP['visual_changes'] = ['clem-halloween'] +ES_SEARCH_INDEX['shards'] = 3 From 9b12929d7e24853bdd0774e61b4d6d8a31effed7 Mon Sep 17 00:00:00 2001 From: Victor Felder Date: Thu, 27 Apr 2017 22:14:49 +0200 Subject: [PATCH 07/75] =?UTF-8?q?V=C3=A9rifie=20que=20le=20tag=20existe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/deploy.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 35d5515e15..7e9b5d4389 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -43,6 +43,15 @@ rm -rf ./dist/ git fetch --tags # Server has git < 1.9, git fetch --tags doesn't retrieve commits... git fetch + +if git rev-parse $1 >/dev/null 2>&1 +then + echo "Tag $1 found!" +else + echo "Tag $1 doesn't exist." + exit 1; +fi + # Checkout the tag git checkout $1-build # Create a branch with the same name - required to have version data in footer From 3db1d824565705e4e54ee54f24096e7dd45f6472 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sun, 7 May 2017 09:43:43 +0200 Subject: [PATCH 08/75] N'affiche que les contenus dont l'auteur est auteur de la version publique sur le profil (#4332) --- zds/tutorialv2/managers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zds/tutorialv2/managers.py b/zds/tutorialv2/managers.py index cf6b371671..d550ab770a 100644 --- a/zds/tutorialv2/managers.py +++ b/zds/tutorialv2/managers.py @@ -41,7 +41,7 @@ def last_contents_of_a_member_loaded(self, author, _type=None): :rtype: django.db.models.QuerySet """ queryset = self.published_contents(_type) \ - .filter(content__authors__in=[author]) + .filter(authors__in=[author]) public_contents = queryset.all()[:settings.ZDS_APP['content']['user_page_number']] return public_contents From a06b161dece3191ee644b5ca5963ac6b7361c156 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sun, 7 May 2017 10:03:04 +0200 Subject: [PATCH 09/75] Ajoute un lien vers les derniers billets (#4320) --- templates/member/profile.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/member/profile.html b/templates/member/profile.html index c25b4fcc62..e175a5675b 100644 --- a/templates/member/profile.html +++ b/templates/member/profile.html @@ -327,6 +327,13 @@

{% trans "Accès rapide" %}

{% endif %} + {% if opinions %} +
  • + + {% trans "Derniers billets" %} + +
  • + {% endif %} {% if profile.biography %}
  • From d7a9ade820d85378316aeab9bf68aeaf9b630728 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sun, 7 May 2017 14:45:51 +0200 Subject: [PATCH 10/75] =?UTF-8?q?Permet=20de=20d=C3=A9sactiver=20l'aide=20?= =?UTF-8?q?Markdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/markdown-help.js | 18 ++++++++++-------- templates/base.html | 9 +++++++-- zds/member/forms.py | 4 ++++ .../0010_profile_show_markdown_help.py | 19 +++++++++++++++++++ zds/member/models.py | 1 + zds/member/tests/tests_views.py | 14 ++++++++++++++ zds/member/views.py | 3 ++- 7 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 zds/member/migrations/0010_profile_show_markdown_help.py diff --git a/assets/js/markdown-help.js b/assets/js/markdown-help.js index ea39044ec4..6535b5ddfd 100644 --- a/assets/js/markdown-help.js +++ b/assets/js/markdown-help.js @@ -24,7 +24,7 @@ "Pour écrire un bout de code au milieu d’une phrase, utilisez la syntaxe `un bout de code`.", "Le langage d’un bloc de code peut être spécifié après les ``` ouvrants. La liste des langages supportés est disponible ici.", "Vous pouvez écrire des formules mathématiques en encadrant ces dernières du signe dollar $." - ]; + ]; function addDocMD($elem){ $elem.each(function(){ @@ -38,12 +38,14 @@ $(document).ready(function(){ - addDocMD($(".md-editor")); - $("#content").on("DOMNodeInserted", ".md-editor", function(e){ - var $editor = $(e.target); - if($editor.next().hasClass("markdown-help") === false) { - addDocMD($editor); - } - }); + if ($("body").data("show-markdown-help")) { + addDocMD($(".md-editor")); + $("#content").on("DOMNodeInserted", ".md-editor", function(e){ + var $editor = $(e.target); + if($editor.next().hasClass("markdown-help") === false) { + addDocMD($editor); + } + }); + } }); })(document, jQuery); diff --git a/templates/base.html b/templates/base.html index 6478d36b6f..d0964560ad 100644 --- a/templates/base.html +++ b/templates/base.html @@ -122,8 +122,13 @@ {% endif %} From 46a0ff1ec77e35cbeb511c163ba12aa39fad87fb Mon Sep 17 00:00:00 2001 From: GCodeur Date: Tue, 2 May 2017 20:47:49 +0200 Subject: [PATCH 19/75] Utilise une instruction de QA --- .github/pull_request_template.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b357d56986..b066cd3c0c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,15 +1,11 @@ | Q | R | ----------------------------------- | ------------------------------------------- | Type de modification | correction de bug / nouvelle fonctionnalité / évolution -| Ticket(s) (_issue(s)_) concerné(s) | (ex #1337) +| Ticket(s) (_issue(s)_) concerné(s) | (ex : #1337) ### QA -* Instruction 1 (ex : lancez `python manage.py migrate` et `npm run gulp build`) -* Instruction 2 -* etc - - - -- [ ] Ça fonctionne ! -- [ ] Code relu et approuvé ! \ No newline at end of file +- Instruction 1 (exemple : lancez `python manage.py migrate` et `npm run gulp build`) +- Instruction 2 +- ... +- Code review \ No newline at end of file From 7e1bf181cd0b91a9c0b1fa7c18f334172c40536e Mon Sep 17 00:00:00 2001 From: GCodeur Date: Thu, 25 May 2017 23:46:23 +0200 Subject: [PATCH 20/75] =?UTF-8?q?Ajoute=20une=20note=20sur=20la=20ligne=20?= =?UTF-8?q?=C3=A9ditoriale=20lors=20de=20l'ajout=20d'un=20contenu=20(#4351?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ajoute une note sur la ligne éditoriale lors de l'ajout d'un contenu * Review de @gustavi + PEP-8 --- templates/tutorialv2/create/content.html | 8 ++++++++ zds/settings.py | 4 +++- zds/tutorialv2/views/views_contents.py | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/templates/tutorialv2/create/content.html b/templates/tutorialv2/create/content.html index 5643d67e23..1425c1bd72 100644 --- a/templates/tutorialv2/create/content.html +++ b/templates/tutorialv2/create/content.html @@ -22,5 +22,13 @@

    {% block content %} +
    +
    + {% blocktrans %} + Vous allez créer un nouveau contenu sur {{ site_name }}. Pensez à prendre connaissance de la ligne éditoriale du site. + {% endblocktrans %} +
    +
    + {% crispy form %} {% endblock %} \ No newline at end of file diff --git a/zds/settings.py b/zds/settings.py index 1f1a2fc7db..0d39621060 100644 --- a/zds/settings.py +++ b/zds/settings.py @@ -506,7 +506,9 @@ 'import_image_prefix': 'archive', 'build_pdf_when_published': True, 'maximum_slug_size': 150, - 'sec_per_minute': 1500 + 'sec_per_minute': 1500, + 'editorial_line_link': + u'https://zestedesavoir.com/articles/222/la-ligne-editoriale-officielle-de-zeste-de-savoir/' }, 'forum': { 'posts_per_page': 21, diff --git a/zds/tutorialv2/views/views_contents.py b/zds/tutorialv2/views/views_contents.py index 502bff4942..b1dc2ba5d7 100644 --- a/zds/tutorialv2/views/views_contents.py +++ b/zds/tutorialv2/views/views_contents.py @@ -87,6 +87,12 @@ def get_form(self, form_class=ContentForm): form.initial['type'] = self.created_content_type return form + def get_context_data(self, **kwargs): + context = super(CreateContent, self).get_context_data(**kwargs) + context['editorial_line_link'] = settings.ZDS_APP['content']['editorial_line_link'] + context['site_name'] = settings.ZDS_APP['site']['litteral_name'] + return context + def form_valid(self, form): # create the object: From b15ddcbb599c131bb07e45f9e84917ea42896a2b Mon Sep 17 00:00:00 2001 From: GCodeur Date: Fri, 26 May 2017 09:19:38 +0200 Subject: [PATCH 21/75] Ajoute le compteur de commentaires sur derniers billets du profil (#4339) --- templates/member/profile.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/member/profile.html b/templates/member/profile.html index e175a5675b..618962d325 100644 --- a/templates/member/profile.html +++ b/templates/member/profile.html @@ -131,7 +131,7 @@

    {% trans "Derniers art

    {% trans "Derniers billets" %}

    {% for public_opinion in opinions %} - {% include 'tutorialv2/includes/content_item.part.html' with show_description=True public_content=public_opinion %} + {% include 'tutorialv2/includes/content_item.part.html' with show_description=True public_content=public_opinion show_reactions=True %} {% endfor %}
    {% endif %} From 0e4367c7f41266dccc4d45dd868e26f083fce192 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sun, 23 Apr 2017 19:03:27 +0200 Subject: [PATCH 22/75] Permet de bannir un fournisseur d'adresses e-mail --- templates/base.html | 3 + .../member/add_banned_email_provider.html | 43 ++++++++++++ templates/member/banned_email_providers.html | 70 +++++++++++++++++++ zds/member/forms.py | 26 ++++++- ...10_bannedemailprovider_newemailprovider.py | 42 +++++++++++ .../migrations/0011_auto_20170423_1749.py | 24 +++++++ zds/member/models.py | 39 +++++++++++ zds/member/urls.py | 9 ++- zds/member/validators.py | 9 +-- zds/member/views.py | 51 ++++++++++++-- zds/settings.py | 1 + 11 files changed, 307 insertions(+), 10 deletions(-) create mode 100644 templates/member/add_banned_email_provider.html create mode 100644 templates/member/banned_email_providers.html create mode 100644 zds/member/migrations/0010_bannedemailprovider_newemailprovider.py create mode 100644 zds/member/migrations/0011_auto_20170423_1749.py diff --git a/templates/base.html b/templates/base.html index d0964560ad..cd87096215 100644 --- a/templates/base.html +++ b/templates/base.html @@ -715,6 +715,9 @@

    {{ headlin
  • {% trans "API" %}
  • {% trans "CGU" %}
  • {% trans "À propos" %}
  • + {% if perms.member.change_profile %} +
  • {% trans "Fournisseurs bannis" %}
  • + {% endif %} {% if app.site.association %}
  • {% trans "L'association" %}
  • {% if user.is_authenticated %} diff --git a/templates/member/add_banned_email_provider.html b/templates/member/add_banned_email_provider.html new file mode 100644 index 0000000000..876027031b --- /dev/null +++ b/templates/member/add_banned_email_provider.html @@ -0,0 +1,43 @@ +{% extends "member/base.html" %} +{% load crispy_forms_tags %} +{% load i18n %} + + +{% block title %} + {% trans "Bannir un fournisseur" %} • {% trans "Gestion des fournisseurs bannis" %} +{% endblock %} + + + +{% block breadcrumb %} +
  • + + {% trans "Gestion des fournisseurs bannis" %} + +
  • +
  • + {% trans "Bannir un fournisseur" %} +
  • +{% endblock %} + + + +{% block headline %} + {% trans "Bannir un fournisseur" %} +{% endblock %} + + + +{% block content %} +
    + {% crispy form %} +
    +{% endblock %} + +{% block sidebar_actions %} + +{% endblock %} \ No newline at end of file diff --git a/templates/member/banned_email_providers.html b/templates/member/banned_email_providers.html new file mode 100644 index 0000000000..af1e8fcecb --- /dev/null +++ b/templates/member/banned_email_providers.html @@ -0,0 +1,70 @@ +{% extends "member/base.html" %} +{% load date %} +{% load i18n %} + + +{% block title %} + {% trans "Gestion des fournisseurs bannis" %} +{% endblock %} + + + +{% block breadcrumb %} +
  • {% trans "Gestion des fournisseurs bannis" %}
  • +{% endblock %} + + + +{% block headline %} + {% trans "Gestion des fournisseurs bannis" %} +{% endblock %} + + + +{% block content %} +

    + {% trans "Vous pouvez ici gérer les fournisseurs d'adresses e-mail bannis. Il n'est pas possible d'utiliser d'adresse e-mail venant de ces fournisseurs." %} +

    + + {% include "misc/paginator.html" with position="top" %} + + {% if providers %} + + + + + + + + + {% for provider in providers %} + + + + + + + {% endfor %} + +
    {% trans "Fournisseur" %}{% trans "Modérateur" %}{% trans "Date du bannissement" %}{% trans "Débannir" %}
    {{ provider.provider }}{% include 'misc/member_item.part.html' with member=provider.moderator avatar=True %}{{ provider.date|format_date|capfirst }} +
    + {% csrf_token %} + +
    +
    + {% else %} + {% trans "Aucun fournisseur n'est banni." %} + {% endif %} + + {% include "misc/paginator.html" with position="bottom" %} +{% endblock %} + + + +{% block sidebar_actions %} + +{% endblock %} \ No newline at end of file diff --git a/zds/member/forms.py b/zds/member/forms.py index 7c46f9065b..fbc16ac08d 100644 --- a/zds/member/forms.py +++ b/zds/member/forms.py @@ -13,7 +13,7 @@ from crispy_forms.layout import HTML, Layout, \ Submit, Field, ButtonHolder, Hidden, Div -from zds.member.models import Profile, KarmaNote +from zds.member.models import Profile, KarmaNote, BannedEmailProvider from zds.member.validators import validate_not_empty, validate_zds_email, validate_zds_username, validate_passwords, \ validate_zds_password from zds.utils.forms import CommonLayoutModalText @@ -590,3 +590,27 @@ def __init__(self, profile, *args, **kwargs): StrictButton(u'Valider', type='submit'), ), ) + + +class BannedEmailProviderForm(forms.ModelForm): + class Meta: + model = BannedEmailProvider + fields = ('provider',) + widgets = { + 'provider': forms.TextInput(attrs={ + 'autofocus': 'on', + 'placeholder': _(u"La partie qui suit l'arobase dans l'adresse e-mail."), + }), + } + + def __init__(self, *args, **kwargs): + super(BannedEmailProviderForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.form_class = 'content-wrapper' + self.helper.form_method = 'post' + + self.helper.layout = Layout( + Field('provider'), + ButtonHolder( + StrictButton(_(u'Bannir ce fournisseur'), type='submit'), + )) diff --git a/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py b/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py new file mode 100644 index 0000000000..0dc3df1b67 --- /dev/null +++ b/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('member', '0009_profile_show_staff_badge'), + ] + + operations = [ + migrations.CreateModel( + name='BannedEmailProvider', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('provider', models.CharField(max_length=253, verbose_name='Fournisseur', db_index=True)), + ('date', models.DateTimeField(db_column='ban_date', auto_now_add=True, verbose_name='Date du bannissement', db_index=True)), + ('moderator', models.ForeignKey(related_name='banned_providers', verbose_name='Mod\xe9rateur', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'Fournisseur banni', + 'verbose_name_plural': 'Fournisseurs bannis', + }, + ), + migrations.CreateModel( + name='NewEmailProvider', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('provider', models.CharField(max_length=253, verbose_name='Fournisseur', db_index=True)), + ('date', models.DateTimeField(db_column='alert_date', auto_now_add=True, verbose_name="Date de l'alerte", db_index=True)), + ('user', models.ForeignKey(related_name='new_providers', verbose_name='Utilisateur concern\xe9', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'Nouveau fournisseur', + 'verbose_name_plural': 'Nouveaux fournisseurs', + }, + ), + ] diff --git a/zds/member/migrations/0011_auto_20170423_1749.py b/zds/member/migrations/0011_auto_20170423_1749.py new file mode 100644 index 0000000000..7fb6b3ca81 --- /dev/null +++ b/zds/member/migrations/0011_auto_20170423_1749.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('member', '0010_bannedemailprovider_newemailprovider'), + ] + + operations = [ + migrations.AlterField( + model_name='bannedemailprovider', + name='provider', + field=models.CharField(unique=True, max_length=253, verbose_name='Fournisseur', db_index=True), + ), + migrations.AlterField( + model_name='newemailprovider', + name='provider', + field=models.CharField(unique=True, max_length=253, verbose_name='Fournisseur', db_index=True), + ), + ] diff --git a/zds/member/models.py b/zds/member/models.py index f8a688a575..b97809fa6e 100644 --- a/zds/member/models.py +++ b/zds/member/models.py @@ -493,6 +493,45 @@ def save_profile(backend, user, response, *args, **kwargs): profile.save() +@python_2_unicode_compatible +class NewEmailProvider(models.Model): + """A new-used email provider which should be checked by a staff member.""" + + class Meta: + verbose_name = 'Nouveau fournisseur' + verbose_name_plural = 'Nouveaux fournisseurs' + + provider = models.CharField('Fournisseur', max_length=253, unique=True, db_index=True) + user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='Utilisateur concerné', + related_name='new_providers', db_index=True) + date = models.DateTimeField(auto_now_add=True, db_index=True, + verbose_name="Date de l'alerte", db_column='alert_date') + + def __str__(self): + return 'Alert about the new provider {}'.format(self.provider) + + +@python_2_unicode_compatible +class BannedEmailProvider(models.Model): + """ + A email provider which has been banned by a staff member. + It cannot be used for registration. + """ + + class Meta: + verbose_name = 'Fournisseur banni' + verbose_name_plural = 'Fournisseurs bannis' + + provider = models.CharField('Fournisseur', max_length=253, unique=True, db_index=True) + moderator = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='Modérateur', + related_name='banned_providers', db_index=True) + date = models.DateTimeField(auto_now_add=True, db_index=True, + verbose_name='Date du bannissement', db_column='ban_date') + + def __str__(self): + return 'Ban of the {} provider'.format(self.provider) + + @python_2_unicode_compatible class Ban(models.Model): """ diff --git a/zds/member/urls.py b/zds/member/urls.py index 5324769659..cd15e45665 100644 --- a/zds/member/urls.py +++ b/zds/member/urls.py @@ -6,7 +6,8 @@ UpdateAvatarMember, UpdatePasswordMember, UpdateUsernameEmailMember, RegisterView, \ SendValidationEmailView, modify_karma, modify_profile, settings_mini_profile, member_from_ip, \ settings_promote, login_view, logout_view, forgot_password, new_password, activate_account, \ - generate_token_account, unregister, warning_unregister + generate_token_account, unregister, warning_unregister, BannedEmailProvidersList, \ + AddBannedEmailProvider, remove_banned_email_provider urlpatterns = [ # list @@ -29,6 +30,12 @@ url(r'^parametres/mini_profil/(?P.+)/$', settings_mini_profile, name='member-settings-mini-profile'), url(r'^profil/multi/(?P.+)/$', member_from_ip, name='member-from-ip'), + # email providers + url(r'^fournisseurs/bannis/$', BannedEmailProvidersList.as_view(), name='banned-email-providers'), + url(r'^fournisseurs/bannis/ajouter/$', AddBannedEmailProvider.as_view(), name='add-banned-email-provider'), + url(r'^fournisseurs/bannis/supprimer/(?P\d+)/$', remove_banned_email_provider, + name='remove-banned-email-provider'), + # user rights url(r'^profil/promouvoir/(?P\d+)/$', settings_promote, name='member-settings-promote'), diff --git a/zds/member/validators.py b/zds/member/validators.py index f0ebf04dae..b42e904d28 100644 --- a/zds/member/validators.py +++ b/zds/member/validators.py @@ -10,6 +10,7 @@ from zds.utils.misc import contains_utf8mb4 from zds.settings import BASE_DIR +from zds.member.models import BannedEmailProvider def validate_not_empty(value): @@ -46,10 +47,10 @@ def __call__(self, value, check_username_available=True): raise ValidationError(self.message, code=self.code) # check if provider is blacklisted - with open(os.path.join(BASE_DIR, 'forbidden_email_providers.txt'), 'r') as black_list: - for provider in black_list: - if provider.strip() in value: - raise ValidationError(_(u'Utilisez un autre fournisseur d\'adresses courriel'), code=self.code) + black_list = BannedEmailProvider.objects.values_list('provider', flat=True) + for provider in black_list: + if '@{}'.format(provider.strip()) in value: + raise ValidationError(_(u'Ce fournisseur ne peut pas être utilisé.'), code=self.code) # check if email is used by another user user_count = User.objects.filter(email=value).count() diff --git a/zds/member/views.py b/zds/member/views.py index c410909f68..f90db7fd7f 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -13,7 +13,7 @@ from django.template.context_processors import csrf from django.core.exceptions import PermissionDenied from django.core.mail import EmailMultiAlternatives -from django.core.urlresolvers import reverse +from django.core.urlresolvers import reverse, reverse_lazy from django.db import transaction from django.db.models import Q from django.http import Http404, HttpResponseBadRequest, StreamingHttpResponse @@ -31,11 +31,13 @@ from zds.gallery.models import UserGallery from zds.member.commons import ProfileCreate, TemporaryReadingOnlySanction, ReadingOnlySanction, \ DeleteReadingOnlySanction, TemporaryBanSanction, BanSanction, DeleteBanSanction, TokenGenerator -from zds.member.decorator import can_write_and_read_now +from zds.member.decorator import can_write_and_read_now, LoginRequiredMixin, PermissionRequiredMixin from zds.member.forms import LoginForm, MiniProfileForm, ProfileForm, RegisterForm, \ ChangePasswordForm, ChangeUserForm, NewPasswordForm, \ - PromoteMemberForm, KarmaForm, UsernameAndEmailForm, GitHubTokenForm -from zds.member.models import Profile, TokenForgotPassword, TokenRegister, KarmaNote, Ban + PromoteMemberForm, KarmaForm, UsernameAndEmailForm, GitHubTokenForm, \ + BannedEmailProviderForm +from zds.member.models import Profile, TokenForgotPassword, TokenRegister, KarmaNote, Ban, \ + BannedEmailProvider from zds.mp.models import PrivatePost, PrivateTopic from zds.notification.models import TopicAnswerSubscription, NewPublicationSubscription from zds.tutorialv2.models.models_database import PublishedContent, PickListOperation @@ -455,6 +457,7 @@ def unregister(request): Ban.objects.filter(moderator=current).update(moderator=anonymous) Alert.objects.filter(author=current).update(author=anonymous) Alert.objects.filter(moderator=current).update(moderator=anonymous) + BannedEmailProvider.objects.filter(moderator=current).update(moderator=anonymous) # in case current has been moderator in his old day Comment.objects.filter(editor=current).update(editor=anonymous) for topic in PrivateTopic.objects.filter(author=current): @@ -596,6 +599,46 @@ def settings_mini_profile(request, user_name): return render(request, 'member/settings/profile.html', data) +class BannedEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagingListView): + permissions = ['member.change_profile'] + paginate_by = paginate_by = settings.ZDS_APP['member']['providers_per_page'] + + model = BannedEmailProvider + context_object_name = 'providers' + template_name = 'member/banned_email_providers.html' + queryset = BannedEmailProvider.objects \ + .select_related('moderator') \ + .select_related('moderator__profile') \ + .order_by('-date') + + +class AddBannedEmailProvider(LoginRequiredMixin, PermissionRequiredMixin, CreateView): + permissions = ['member.change_profile'] + + model = BannedEmailProvider + template_name = 'member/add_banned_email_provider.html' + form_class = BannedEmailProviderForm + success_url = reverse_lazy('banned-email-providers') + + def form_valid(self, form): + form.instance.moderator = self.request.user + messages.success(self.request, _(u'Le fournisseur a été banni.')) + return super(AddBannedEmailProvider, self).form_valid(form) + + +@require_POST +@login_required +@permission_required('member.change_profile', raise_exception=True) +def remove_banned_email_provider(request, provider_pk): + """Used to unban a email provider""" + + provider = get_object_or_404(BannedEmailProvider, pk=provider_pk) + provider.delete() + + messages.success(request, _(u'Le fournisseur a été débanni.')) + return redirect('banned-email-providers') + + def login_view(request): """Log in user.""" diff --git a/zds/settings.py b/zds/settings.py index 0d39621060..81c0141ed4 100644 --- a/zds/settings.py +++ b/zds/settings.py @@ -462,6 +462,7 @@ 'bot_group': u'bot', 'dev_group': u'devs', 'members_per_page': 100, + 'providers_per_page': 21, 'update_last_visit_interval': 600, # seconds }, 'gallery': { From 5347e993cfca2b64892621c043cc56cadfa60528 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sun, 23 Apr 2017 19:43:02 +0200 Subject: [PATCH 23/75] =?UTF-8?q?Permet=20de=20g=C3=A9rer=20les=20nouveaux?= =?UTF-8?q?=20fournisseurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/member/banned_email_providers.html | 4 ++ templates/member/new_email_providers.html | 71 ++++++++++++++++++++ zds/member/urls.py | 7 +- zds/member/views.py | 31 ++++++++- 4 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 templates/member/new_email_providers.html diff --git a/templates/member/banned_email_providers.html b/templates/member/banned_email_providers.html index af1e8fcecb..ccd79152c3 100644 --- a/templates/member/banned_email_providers.html +++ b/templates/member/banned_email_providers.html @@ -66,5 +66,9 @@ {% trans "Bannir" %} {% trans "un fournisseur" %} + + + {% trans "Nouveaux fournisseurs" %} +

  • {% endblock %} \ No newline at end of file diff --git a/templates/member/new_email_providers.html b/templates/member/new_email_providers.html new file mode 100644 index 0000000000..de68eb5997 --- /dev/null +++ b/templates/member/new_email_providers.html @@ -0,0 +1,71 @@ +{% extends "member/base.html" %} +{% load date %} +{% load i18n %} + + +{% block title %} + {% trans "Fournisseurs en attente de vérification" %} +{% endblock %} + + + +{% block breadcrumb %} +
  • {% trans "Fournisseurs en attente de vérification" %}
  • +{% endblock %} + + + +{% block headline %} + {% trans "Fournisseurs en attente de vérification" %} +{% endblock %} + + + +{% block content %} +

    + {% trans "Vous pouvez ici vérifier les nouveaux fournisseurs d'adresses e-mail afin de s'assurer qu'ils ne génèrent pas d'adresses e-mail jetables. Bannir un fournisseur empêchera de futures inscriptions avec une de ses adresses e-mail, mais le compte concerné restera actif (sauf action contraire)." %} +

    + + {% include "misc/paginator.html" with position="top" %} + + {% if providers %} + + + + + + + + + {% for provider in providers %} + + + + + + + {% endfor %} + +
    {% trans "Fournisseur" %}{% trans "Compte concerné" %}{% trans "Date d'utilisation" %}{% trans "Actions" %}
    {{ provider.provider }}{% include 'misc/member_item.part.html' with member=provider.user avatar=True %}{{ provider.date|format_date|capfirst }} +
    + {% csrf_token %} + + +
    +
    + {% else %} + {% trans "Aucun fournisseur n'est actuellement en attente de vérification." %} + {% endif %} + + {% include "misc/paginator.html" with position="bottom" %} +{% endblock %} + + + +{% block sidebar_actions %} +
    + + {% trans "Fournisseurs bannis" %} + +
    +{% endblock %} \ No newline at end of file diff --git a/zds/member/urls.py b/zds/member/urls.py index cd15e45665..b804280089 100644 --- a/zds/member/urls.py +++ b/zds/member/urls.py @@ -6,8 +6,8 @@ UpdateAvatarMember, UpdatePasswordMember, UpdateUsernameEmailMember, RegisterView, \ SendValidationEmailView, modify_karma, modify_profile, settings_mini_profile, member_from_ip, \ settings_promote, login_view, logout_view, forgot_password, new_password, activate_account, \ - generate_token_account, unregister, warning_unregister, BannedEmailProvidersList, \ - AddBannedEmailProvider, remove_banned_email_provider + generate_token_account, unregister, warning_unregister, BannedEmailProvidersList, NewEmailProvidersList, \ + AddBannedEmailProvider, remove_banned_email_provider, check_new_email_provider urlpatterns = [ # list @@ -31,6 +31,9 @@ url(r'^profil/multi/(?P.+)/$', member_from_ip, name='member-from-ip'), # email providers + url(r'^fournisseurs/nouveaux/$', NewEmailProvidersList.as_view(), name='new-email-providers'), + url(r'^fournisseurs/nouveaux/verifier/(?P\d+)/$', check_new_email_provider, + name='check-new-email-provider'), url(r'^fournisseurs/bannis/$', BannedEmailProvidersList.as_view(), name='banned-email-providers'), url(r'^fournisseurs/bannis/ajouter/$', AddBannedEmailProvider.as_view(), name='add-banned-email-provider'), url(r'^fournisseurs/bannis/supprimer/(?P\d+)/$', remove_banned_email_provider, diff --git a/zds/member/views.py b/zds/member/views.py index f90db7fd7f..639581f014 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -37,7 +37,7 @@ PromoteMemberForm, KarmaForm, UsernameAndEmailForm, GitHubTokenForm, \ BannedEmailProviderForm from zds.member.models import Profile, TokenForgotPassword, TokenRegister, KarmaNote, Ban, \ - BannedEmailProvider + BannedEmailProvider, NewEmailProvider from zds.mp.models import PrivatePost, PrivateTopic from zds.notification.models import TopicAnswerSubscription, NewPublicationSubscription from zds.tutorialv2.models.models_database import PublishedContent, PickListOperation @@ -599,6 +599,35 @@ def settings_mini_profile(request, user_name): return render(request, 'member/settings/profile.html', data) +class NewEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagingListView): + permissions = ['member.change_profile'] + paginate_by = paginate_by = settings.ZDS_APP['member']['providers_per_page'] + + model = NewEmailProvider + context_object_name = 'providers' + template_name = 'member/new_email_providers.html' + queryset = NewEmailProvider.objects \ + .select_related('user') \ + .select_related('user__profile') \ + .order_by('-date') + + +@require_POST +@login_required +@permission_required('member.change_profile', raise_exception=True) +def check_new_email_provider(request, provider_pk): + """Remove an alert about a new provider""" + + provider = get_object_or_404(NewEmailProvider, pk=provider_pk) + if 'ban' in request.POST \ + and not BannedEmailProvider.objects.filter(provider=provider.provider).exists(): + BannedEmailProvider.objects.create(provider=provider.provider, moderator=request.user) + provider.delete() + + messages.success(request, _(u'Action effectuée.')) + return redirect('new-email-providers') + + class BannedEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagingListView): permissions = ['member.change_profile'] paginate_by = paginate_by = settings.ZDS_APP['member']['providers_per_page'] From 1ce5a964d3fa9e449d54ede00e908347fb1f5025 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Tue, 25 Apr 2017 19:08:47 +0200 Subject: [PATCH 24/75] =?UTF-8?q?Cr=C3=A9ation=20des=20alertes=20et=20nomb?= =?UTF-8?q?re=20d'alertes=20pour=20le=20staff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base.html | 16 +++++++++++++--- templates/member/new_email_providers.html | 15 +++++++++++++-- zds/member/admin.py | 19 ++++++++++++++++++- zds/member/validators.py | 8 ++++---- zds/member/views.py | 13 +++++++++++++ zds/utils/templatetags/interventions.py | 7 +++++++ 6 files changed, 68 insertions(+), 10 deletions(-) diff --git a/templates/base.html b/templates/base.html index cd87096215..8aaa3171a3 100644 --- a/templates/base.html +++ b/templates/base.html @@ -595,6 +595,19 @@ {% endwith %} {% endif %} + {% if perms.member.change_profile %} + {% with new_providers_count=user|new_providers_count %} +
  • + + {% trans "Nouveaux fournisseurs" %} + {% if new_providers_count > 0 %} + ({{ new_providers_count }}) + {% endif %} + +
  • + {% endwith %} + {% endif %} + {% if perms.featured.change_featuredresource %}
  • {% trans 'Gestion des mises en avant' %} @@ -715,9 +728,6 @@

    {{ headlin
  • {% trans "API" %}
  • {% trans "CGU" %}
  • {% trans "À propos" %}
  • - {% if perms.member.change_profile %} -
  • {% trans "Fournisseurs bannis" %}
  • - {% endif %} {% if app.site.association %}
  • {% trans "L'association" %}
  • {% if user.is_authenticated %} diff --git a/templates/member/new_email_providers.html b/templates/member/new_email_providers.html index de68eb5997..3f83f22bd9 100644 --- a/templates/member/new_email_providers.html +++ b/templates/member/new_email_providers.html @@ -4,13 +4,20 @@ {% block title %} - {% trans "Fournisseurs en attente de vérification" %} + {% trans "Fournisseurs en attente de vérification" %} • {% trans "Gestion des fournisseurs bannis" %} {% endblock %} {% block breadcrumb %} -
  • {% trans "Fournisseurs en attente de vérification" %}
  • +
  • + + {% trans "Gestion des fournisseurs bannis" %} + +
  • +
  • + {% trans "Fournisseurs en attente de vérification" %} +
  • {% endblock %} @@ -67,5 +74,9 @@ {% trans "Fournisseurs bannis" %} + + + {% trans "Bannir" %} {% trans "un fournisseur" %} + {% endblock %} \ No newline at end of file diff --git a/zds/member/admin.py b/zds/member/admin.py index 3c276ee6b4..352c6a6b36 100644 --- a/zds/member/admin.py +++ b/zds/member/admin.py @@ -2,7 +2,8 @@ from django.contrib import admin -from zds.member.models import Profile, Ban, TokenRegister, TokenForgotPassword, KarmaNote +from zds.member.models import Profile, Ban, TokenRegister, TokenForgotPassword, KarmaNote, \ + NewEmailProvider, BannedEmailProvider class ProfileAdmin(admin.ModelAdmin): @@ -42,8 +43,24 @@ class KarmaNoteAdmin(admin.ModelAdmin): raw_id_fields = ('user', 'moderator') +class NewEmailProviderAdmin(admin.ModelAdmin): + """Representation of NewEmailProvider model in the admin interface.""" + list_display = ('provider', 'user', 'date') + search_fields = ('provider', 'user__username') + raw_id_fields = ('user',) + + +class BannedEmailProviderAdmin(admin.ModelAdmin): + """Representation of BannedEmailProvider model in the admin interface.""" + list_display = ('provider', 'moderator', 'date') + search_fields = ('provider',) + raw_id_fields = ('moderator',) + + admin.site.register(Profile, ProfileAdmin) admin.site.register(Ban, BanAdmin) admin.site.register(TokenRegister, TokenRegisterAdmin) admin.site.register(TokenForgotPassword, TokenForgotPasswordAdmin) admin.site.register(KarmaNote, KarmaNoteAdmin) +admin.site.register(NewEmailProvider, NewEmailProviderAdmin) +admin.site.register(BannedEmailProvider, BannedEmailProviderAdmin) diff --git a/zds/member/validators.py b/zds/member/validators.py index b42e904d28..efea15fb75 100644 --- a/zds/member/validators.py +++ b/zds/member/validators.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os +import re from django.contrib.auth.models import User from django.core.exceptions import ValidationError @@ -47,10 +48,9 @@ def __call__(self, value, check_username_available=True): raise ValidationError(self.message, code=self.code) # check if provider is blacklisted - black_list = BannedEmailProvider.objects.values_list('provider', flat=True) - for provider in black_list: - if '@{}'.format(provider.strip()) in value: - raise ValidationError(_(u'Ce fournisseur ne peut pas être utilisé.'), code=self.code) + provider = re.findall(r'@(.+)', value)[0] + if BannedEmailProvider.objects.filter(provider=provider).exists(): + raise ValidationError(_(u'Ce fournisseur ne peut pas être utilisé.'), code=self.code) # check if email is used by another user user_count = User.objects.filter(email=value).count() diff --git a/zds/member/views.py b/zds/member/views.py index 639581f014..983440360c 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -2,6 +2,7 @@ import uuid from datetime import datetime, timedelta +import re from oauth2_provider.models import AccessToken @@ -320,6 +321,11 @@ def update_profile(self, profile, form): profile.user.username = new_username if new_email and new_email != previous_email: profile.user.email = new_email + # create an alert for staff if it's a new provider + provider = re.findall(r'@(.+)', new_email)[0] + if not NewEmailProvider.objects.filter(provider=provider).exists() \ + and not User.objects.filter(email__endswith='@{}'.format(provider)): + NewEmailProvider.objects.create(user=profile.user, provider=provider) def get_success_url(self): profile = self.get_object() @@ -854,6 +860,13 @@ def activate_account(request): } ) + # create an alert for staff if it's a new provider + if usr.email: + provider = re.findall(r'@(.+)', usr.email)[0] + if not NewEmailProvider.objects.filter(provider=provider).exists() \ + and not User.objects.filter(email__endswith='@{}'.format(provider)): + NewEmailProvider.objects.create(user=usr, provider=provider) + send_mp(bot, [usr], _(u'Bienvenue sur {}').format(settings.ZDS_APP['site']['litteral_name']), diff --git a/zds/utils/templatetags/interventions.py b/zds/utils/templatetags/interventions.py index f472d07a6f..45c26814bf 100644 --- a/zds/utils/templatetags/interventions.py +++ b/zds/utils/templatetags/interventions.py @@ -17,6 +17,7 @@ from zds.utils.models import Alert from zds import settings from zds.tutorialv2.models import TYPE_CHOICES_DICT +from zds.member.models import NewEmailProvider register = template.Library() @@ -212,7 +213,13 @@ def waiting_count(content_type): """ if content_type not in TYPE_CHOICES_DICT: raise template.TemplateSyntaxError("'content_type' must be in 'zds.tutorialv2.models.TYPE_CHOICES_DICT'") + return Validation.objects.filter( validator__isnull=True, status='PENDING', content__type=content_type).count() + + +@register.filter(name='new_providers_count') +def new_providers_count(user): + return NewEmailProvider.objects.count() From 125e34efbc393be4da6997b0c495681c13ad5af8 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Tue, 25 Apr 2017 19:10:07 +0200 Subject: [PATCH 25/75] Une seule migration --- ...10_bannedemailprovider_newemailprovider.py | 4 ++-- .../migrations/0011_auto_20170423_1749.py | 24 ------------------- 2 files changed, 2 insertions(+), 26 deletions(-) delete mode 100644 zds/member/migrations/0011_auto_20170423_1749.py diff --git a/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py b/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py index 0dc3df1b67..59016a8966 100644 --- a/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py +++ b/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py @@ -17,7 +17,7 @@ class Migration(migrations.Migration): name='BannedEmailProvider', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('provider', models.CharField(max_length=253, verbose_name='Fournisseur', db_index=True)), + ('provider', models.CharField(unique=True, max_length=253, verbose_name='Fournisseur', db_index=True)), ('date', models.DateTimeField(db_column='ban_date', auto_now_add=True, verbose_name='Date du bannissement', db_index=True)), ('moderator', models.ForeignKey(related_name='banned_providers', verbose_name='Mod\xe9rateur', to=settings.AUTH_USER_MODEL)), ], @@ -30,7 +30,7 @@ class Migration(migrations.Migration): name='NewEmailProvider', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('provider', models.CharField(max_length=253, verbose_name='Fournisseur', db_index=True)), + ('provider', models.CharField(unique=True, max_length=253, verbose_name='Fournisseur', db_index=True)), ('date', models.DateTimeField(db_column='alert_date', auto_now_add=True, verbose_name="Date de l'alerte", db_index=True)), ('user', models.ForeignKey(related_name='new_providers', verbose_name='Utilisateur concern\xe9', to=settings.AUTH_USER_MODEL)), ], diff --git a/zds/member/migrations/0011_auto_20170423_1749.py b/zds/member/migrations/0011_auto_20170423_1749.py deleted file mode 100644 index 7fb6b3ca81..0000000000 --- a/zds/member/migrations/0011_auto_20170423_1749.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('member', '0010_bannedemailprovider_newemailprovider'), - ] - - operations = [ - migrations.AlterField( - model_name='bannedemailprovider', - name='provider', - field=models.CharField(unique=True, max_length=253, verbose_name='Fournisseur', db_index=True), - ), - migrations.AlterField( - model_name='newemailprovider', - name='provider', - field=models.CharField(unique=True, max_length=253, verbose_name='Fournisseur', db_index=True), - ), - ] From eb48c3d2866f59179b01cba94a76b7d9d433a6ed Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 6 May 2017 11:54:57 +0200 Subject: [PATCH 26/75] Corrige la pagination --- zds/member/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zds/member/views.py b/zds/member/views.py index 983440360c..89033f52d7 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -607,7 +607,7 @@ def settings_mini_profile(request, user_name): class NewEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagingListView): permissions = ['member.change_profile'] - paginate_by = paginate_by = settings.ZDS_APP['member']['providers_per_page'] + paginate_by = settings.ZDS_APP['member']['providers_per_page'] model = NewEmailProvider context_object_name = 'providers' @@ -636,7 +636,7 @@ def check_new_email_provider(request, provider_pk): class BannedEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagingListView): permissions = ['member.change_profile'] - paginate_by = paginate_by = settings.ZDS_APP['member']['providers_per_page'] + paginate_by = settings.ZDS_APP['member']['providers_per_page'] model = BannedEmailProvider context_object_name = 'providers' From 05eb8dac96f4bebd698042da58460a2cf0aa7260 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 6 May 2017 12:00:24 +0200 Subject: [PATCH 27/75] Utilise la bonne permission --- templates/base.html | 2 +- update.md | 9 +++++++++ zds/member/views.py | 10 +++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/templates/base.html b/templates/base.html index 8aaa3171a3..7319a3e920 100644 --- a/templates/base.html +++ b/templates/base.html @@ -595,7 +595,7 @@ {% endwith %} {% endif %} - {% if perms.member.change_profile %} + {% if perms.member.change_bannedemailprovider %} {% with new_providers_count=user|new_providers_count %}
  • diff --git a/update.md b/update.md index f2b0cf89ff..8bf7c60c35 100644 --- a/update.md +++ b/update.md @@ -1042,3 +1042,12 @@ Mise à jour d'ElasticSearch 1. `sudo apt update` 2. `sudo apt upgrade elasticsearch` 2. `systemctl restart elasticsearch.service` + + +Actions à faire pour mettre en prod la version : v24 +==================================================== + +Ticket #4313 +----------- + +Via l'admin Django, ajouter la permission `member.change_bannedemailprovider` aux groupes autorisés à gérer les fournisseurs e-mail bannis. \ No newline at end of file diff --git a/zds/member/views.py b/zds/member/views.py index 89033f52d7..53e0d02a3b 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -606,7 +606,7 @@ def settings_mini_profile(request, user_name): class NewEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagingListView): - permissions = ['member.change_profile'] + permissions = ['member.change_bannedemailprovider'] paginate_by = settings.ZDS_APP['member']['providers_per_page'] model = NewEmailProvider @@ -620,7 +620,7 @@ class NewEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagi @require_POST @login_required -@permission_required('member.change_profile', raise_exception=True) +@permission_required('member.change_bannedemailprovider', raise_exception=True) def check_new_email_provider(request, provider_pk): """Remove an alert about a new provider""" @@ -635,7 +635,7 @@ def check_new_email_provider(request, provider_pk): class BannedEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagingListView): - permissions = ['member.change_profile'] + permissions = ['member.change_bannedemailprovider'] paginate_by = settings.ZDS_APP['member']['providers_per_page'] model = BannedEmailProvider @@ -648,7 +648,7 @@ class BannedEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSP class AddBannedEmailProvider(LoginRequiredMixin, PermissionRequiredMixin, CreateView): - permissions = ['member.change_profile'] + permissions = ['member.change_bannedemailprovider'] model = BannedEmailProvider template_name = 'member/add_banned_email_provider.html' @@ -663,7 +663,7 @@ def form_valid(self, form): @require_POST @login_required -@permission_required('member.change_profile', raise_exception=True) +@permission_required('member.change_bannedemailprovider', raise_exception=True) def remove_banned_email_provider(request, provider_pk): """Used to unban a email provider""" From 1d096b3ede516387482d6af4156ada11a5580956 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 6 May 2017 12:27:43 +0200 Subject: [PATCH 28/75] =?UTF-8?q?Distingue=20inscription=20et=20=C3=A9diti?= =?UTF-8?q?on=20de=20l'e-mail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/member/new_email_providers.html | 2 ++ zds/member/__init__.py | 7 +++++++ .../0010_bannedemailprovider_newemailprovider.py | 1 + zds/member/models.py | 2 ++ zds/member/views.py | 4 ++-- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/templates/member/new_email_providers.html b/templates/member/new_email_providers.html index 3f83f22bd9..0340fa72ae 100644 --- a/templates/member/new_email_providers.html +++ b/templates/member/new_email_providers.html @@ -39,6 +39,7 @@ + @@ -47,6 +48,7 @@ {% for provider in providers %} + - + {% for provider in providers %} @@ -47,6 +47,7 @@ {% csrf_token %} + {% trans "Comptes avec ce fournisseur" %} {% endfor %} diff --git a/templates/member/members_with_provider.html b/templates/member/members_with_provider.html new file mode 100644 index 0000000000..45eaaa867b --- /dev/null +++ b/templates/member/members_with_provider.html @@ -0,0 +1,53 @@ +{% extends "member/base.html" %} +{% load date %} +{% load i18n %} +{% load remove_url_protocole %} + +{% block title %} + {% trans "Membres utilisant un fournisseur" %} +{% endblock %} + + + +{% block breadcrumb %} +
  • {% trans "Gestion des fournisseurs bannis" %}
  • +
  • {% trans "Recherche de membres :" %} {{ provider.provider }}
  • +{% endblock %} + + + +{% block headline %} + {% trans "Recherche de membres :" %} {{ provider.provider }} +{% endblock %} + + + +{% block content %} + {% blocktrans with provider_name=provider.provider %} + Liste des membres utilisant une adresse e-mail fournie par {{ provider_name }} : + {% endblocktrans %} + +
    +
      + {% for member in members %} +
    • + {% include "misc/member_item.part.html" with avatar=True %} +
    • + {% empty %} +
    • + {% trans "Aucun membre n'utilise ce fournisseur." %} +
    • + {% endfor %} +
    +
    +{% endblock %} + + + +{% block sidebar_actions %} + +{% endblock %} \ No newline at end of file diff --git a/zds/member/urls.py b/zds/member/urls.py index b804280089..11b4c3776d 100644 --- a/zds/member/urls.py +++ b/zds/member/urls.py @@ -7,7 +7,7 @@ SendValidationEmailView, modify_karma, modify_profile, settings_mini_profile, member_from_ip, \ settings_promote, login_view, logout_view, forgot_password, new_password, activate_account, \ generate_token_account, unregister, warning_unregister, BannedEmailProvidersList, NewEmailProvidersList, \ - AddBannedEmailProvider, remove_banned_email_provider, check_new_email_provider + AddBannedEmailProvider, remove_banned_email_provider, check_new_email_provider, MembersWithProviderList urlpatterns = [ # list @@ -36,6 +36,8 @@ name='check-new-email-provider'), url(r'^fournisseurs/bannis/$', BannedEmailProvidersList.as_view(), name='banned-email-providers'), url(r'^fournisseurs/bannis/ajouter/$', AddBannedEmailProvider.as_view(), name='add-banned-email-provider'), + url(r'^fournisseurs/bannis/rechercher/(?P\d+)/$', MembersWithProviderList.as_view(), + name='members-with-provider'), url(r'^fournisseurs/bannis/supprimer/(?P\d+)/$', remove_banned_email_provider, name='remove-banned-email-provider'), diff --git a/zds/member/views.py b/zds/member/views.py index 2bd7d103e7..ec718d045d 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -25,7 +25,7 @@ from django.utils.translation import string_concat from django.utils.translation import ugettext_lazy as _ from django.views.decorators.http import require_POST -from django.views.generic import DetailView, UpdateView, CreateView, FormView +from django.views.generic import DetailView, ListView, UpdateView, CreateView, FormView from zds.forum.models import Topic, TopicRead from zds.gallery.forms import ImageAsAvatarForm @@ -648,6 +648,29 @@ class BannedEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSP .order_by('-date') +class MembersWithProviderList(LoginRequiredMixin, PermissionRequiredMixin, ListView): + permissions = ['member.change_bannedemailprovider'] + + model = User + context_object_name = 'members' + template_name = 'member/members_with_provider.html' + + def get_object(self): + return get_object_or_404(BannedEmailProvider, pk=self.kwargs['provider_pk']) + + def get_context_data(self, **kwargs): + context = super(MembersWithProviderList, self).get_context_data(**kwargs) + context['provider'] = self.get_object() + return context + + def get_queryset(self): + provider = self.get_object() + return Profile.objects \ + .select_related('user') \ + .order_by('-last_visit') \ + .filter(user__email__endswith='@{}'.format(provider.provider)) + + class AddBannedEmailProvider(LoginRequiredMixin, PermissionRequiredMixin, CreateView): permissions = ['member.change_bannedemailprovider'] From d6a3bc399517a713becb12e0b1301b40ef390740 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Tue, 9 May 2017 18:53:09 +0200 Subject: [PATCH 36/75] Tests + recherche via le fournisseur --- templates/member/members_with_provider.html | 4 + zds/member/api/tests.py | 3 +- zds/member/tests/tests_forms.py | 6 +- zds/member/tests/tests_views.py | 155 +++++++++++++++++++- zds/member/views.py | 5 +- 5 files changed, 167 insertions(+), 6 deletions(-) diff --git a/templates/member/members_with_provider.html b/templates/member/members_with_provider.html index 45eaaa867b..eab77d0c76 100644 --- a/templates/member/members_with_provider.html +++ b/templates/member/members_with_provider.html @@ -27,6 +27,8 @@ Liste des membres utilisant une adresse e-mail fournie par {{ provider_name }} : {% endblocktrans %} + {% include "misc/paginator.html" with position="top" %} +
      {% for member in members %} @@ -40,6 +42,8 @@ {% endfor %}
    + + {% include "misc/paginator.html" with position="bottom" %} {% endblock %} diff --git a/zds/member/api/tests.py b/zds/member/api/tests.py index 35cbdf5e9b..b7a79da963 100644 --- a/zds/member/api/tests.py +++ b/zds/member/api/tests.py @@ -242,7 +242,8 @@ def test_register_new_user_with_forbidden_email(self): Gets an error when the user tries to register a new user with a forbidden email. """ moderator = StaffProfileFactory().user - BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) + if not BannedEmailProvider.objects.filter(provider='yopmail.com').exists(): + BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) data = { 'username': 'Clem', 'email': 'clem@yopmail.com', diff --git a/zds/member/tests/tests_forms.py b/zds/member/tests/tests_forms.py index a3354f6b13..bb5ea19670 100644 --- a/zds/member/tests/tests_forms.py +++ b/zds/member/tests/tests_forms.py @@ -113,7 +113,8 @@ def test_empty_spaces_username_register_form(self): def test_forbidden_email_provider_register_form(self): moderator = StaffProfileFactory().user - BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) + if not BannedEmailProvider.objects.filter(provider='yopmail.com').exists(): + BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) data = { 'email': 'test@yopmail.com', 'username': 'ZeTester', @@ -313,7 +314,8 @@ def test_already_used_email_user_form(self): def test_forbidden_email_provider_user_form(self): moderator = StaffProfileFactory().user - BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) + if not BannedEmailProvider.objects.filter(provider='yopmail.com').exists(): + BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) data = { 'username': self.user1.user.username, 'email': 'test@yopmail.com' diff --git a/zds/member/tests/tests_views.py b/zds/member/tests/tests_views.py index 015d24bd44..9249adf5a2 100644 --- a/zds/member/tests/tests_views.py +++ b/zds/member/tests/tests_views.py @@ -21,7 +21,7 @@ from zds.mp.factories import PrivateTopicFactory, PrivatePostFactory from zds.member.models import Profile, KarmaNote, TokenForgotPassword from zds.mp.models import PrivatePost, PrivateTopic -from zds.member.models import TokenRegister, Ban +from zds.member.models import TokenRegister, Ban, NewEmailProvider, BannedEmailProvider from zds.tutorialv2.factories import PublishableContentFactory, PublishedContentFactory, BetaContentFactory from zds.tutorialv2.models.models_database import PublishableContent, PublishedContent from zds.forum.factories import CategoryFactory, ForumFactory, TopicFactory, PostFactory @@ -1209,6 +1209,159 @@ def test_markdown_help_settings(self): result = self.client.get(reverse('pages-index'), follow=False) self.assertContains(result, 'data-show-markdown-help="false"') + def test_new_provider_with_new_account(self): + new_providers_count = NewEmailProvider.objects.count() + + # register a new user + self.client.post(reverse('register-member'), { + 'username': 'new', + 'password': 'hostel77', + 'password_confirm': 'hostel77', + 'email': 'test@unknown-provider-register.com', + }, follow=False) + + user = User.objects.get(username='new') + token = TokenRegister.objects.get(user=user) + self.client.get(token.get_absolute_url(), follow=False) + + # A new provider object should have been created + self.assertEqual(new_providers_count + 1, NewEmailProvider.objects.count()) + + def test_new_provider_with_email_edit(self): + new_providers_count = NewEmailProvider.objects.count() + user = ProfileFactory().user + self.client.login(username=user.username, password='hostel77') + # Edit the email with an unknown provider + self.client.post(reverse('update-username-email-member'), { + 'username': user.username, + 'email': 'test@unknown-provider-edit.com' + }, follow=False) + # A new provider object should have been created + self.assertEqual(new_providers_count + 1, NewEmailProvider.objects.count()) + + def test_new_providers_list(self): + # create a new provider + user = ProfileFactory().user + provider = NewEmailProvider.objects.create(use='NEW_ACCOUNT', user=user, + provider='test.com') + # check that the list is not available for a non-staff member + self.client.logout() + result = self.client.get(reverse('new-email-providers'), follow=False) + self.assertEqual(result.status_code, 302) + self.client.login(username=user.username, password='hostel77') + result = self.client.get(reverse('new-email-providers'), follow=False) + self.assertEqual(result.status_code, 403) + # and that it contains the provider we created + self.client.login(username=self.staff.username, password='hostel77') + result = self.client.get(reverse('new-email-providers'), follow=False) + self.assertEqual(result.status_code, 200) + self.assertIn(provider, result.context['providers']) + + def test_check_new_provider(self): + # create two new providers + user = ProfileFactory().user + provider1 = NewEmailProvider.objects.create(use='NEW_ACCOUNT', user=user, + provider='test1.com') + provider2 = NewEmailProvider.objects.create(use='EMAIl_EDIT', user=user, + provider='test2.com') + # check that this option is only available for a staff member + self.client.login(username=user.username, password='hostel77') + result = self.client.post(reverse('check-new-email-provider', args=[provider1.pk]), follow=False) + self.assertEqual(result.status_code, 403) + # test approval + self.client.login(username=self.staff.username, password='hostel77') + result = self.client.post(reverse('check-new-email-provider', args=[provider1.pk]), follow=False) + self.assertEqual(result.status_code, 302) + self.assertFalse(NewEmailProvider.objects.filter(pk=provider1.pk).exists()) + self.assertFalse(BannedEmailProvider.objects.filter(provider=provider1.provider).exists()) + # test ban + self.client.login(username=self.staff.username, password='hostel77') + result = self.client.post(reverse('check-new-email-provider', args=[provider2.pk]), + {'ban': 'on'}, follow=False) + self.assertEqual(result.status_code, 302) + self.assertFalse(NewEmailProvider.objects.filter(pk=provider2.pk).exists()) + self.assertTrue(BannedEmailProvider.objects.filter(provider=provider2.provider).exists()) + + def test_banned_providers_list(self): + user = ProfileFactory().user + # create a banned provider + provider = BannedEmailProvider.objects.create(moderator=self.staff, provider='test.com') + # check that the list is not available for a non-staff member + self.client.logout() + result = self.client.get(reverse('banned-email-providers'), follow=False) + self.assertEqual(result.status_code, 302) + self.client.login(username=user.username, password='hostel77') + result = self.client.get(reverse('banned-email-providers'), follow=False) + self.assertEqual(result.status_code, 403) + # and that it contains the provider we created + self.client.login(username=self.staff.username, password='hostel77') + result = self.client.get(reverse('banned-email-providers'), follow=False) + self.assertEqual(result.status_code, 200) + self.assertIn(provider, result.context['providers']) + + def test_add_banned_provider(self): + # test that this page is only available for staff + user = ProfileFactory().user + self.client.logout() + result = self.client.get(reverse('add-banned-email-provider'), follow=False) + self.assertEqual(result.status_code, 302) + self.client.login(username=user.username, password='hostel77') + result = self.client.get(reverse('add-banned-email-provider'), follow=False) + self.assertEqual(result.status_code, 403) + self.client.login(username=self.staff.username, password='hostel77') + result = self.client.get(reverse('add-banned-email-provider'), follow=False) + self.assertEqual(result.status_code, 200) + + # add a provider + result = self.client.post(reverse('add-banned-email-provider'), + {'provider': 'new-provider.com'}, follow=False) + self.assertEqual(result.status_code, 302) + self.assertTrue(BannedEmailProvider.objects.filter(provider='new-provider.com').exists()) + + # check that it cannot be added again + result = self.client.post(reverse('add-banned-email-provider'), + {'provider': 'new-provider.com'}, follow=False) + self.assertEqual(result.status_code, 200) + self.assertEqual(1, BannedEmailProvider.objects.filter(provider='new-provider.com').count()) + + def test_members_with_provider(self): + # create two members with the same provider + member1 = ProfileFactory().user + member2 = ProfileFactory().user + member1.email = 'test1@test-members.com' + member1.save() + member2.email = 'test2@test-members.com' + member2.save() + # ban this provider + provider = BannedEmailProvider.objects.create(moderator=self.staff, provider='test-members.com') + # check that this page is only available for staff + self.client.logout() + result = self.client.get(reverse('members-with-provider', args=[provider.pk]), follow=False) + self.assertEqual(result.status_code, 302) + self.client.login(username=member1.username, password='hostel77') + result = self.client.get(reverse('members-with-provider', args=[provider.pk]), follow=False) + self.assertEqual(result.status_code, 403) + self.client.login(username=self.staff.username, password='hostel77') + result = self.client.get(reverse('members-with-provider', args=[provider.pk]), follow=False) + self.assertEqual(result.status_code, 200) + # check that it contains the two members + self.assertIn(member1.profile, result.context['members']) + self.assertIn(member2.profile, result.context['members']) + + def test_remove_banned_provider(self): + user = ProfileFactory().user + # add a banned provider + provider = BannedEmailProvider.objects.create(moderator=self.staff, provider='test-remove.com') + # check that this option is only available for a staff member + self.client.login(username=user.username, password='hostel77') + result = self.client.post(reverse('check-new-email-provider', args=[provider.pk]), follow=False) + self.assertEqual(result.status_code, 403) + # test that it removes the provider + self.client.login(username=self.staff.username, password='hostel77') + result = self.client.post(reverse('remove-banned-email-provider', args=[provider.pk]), follow=False) + self.assertEqual(result.status_code, 302) + self.assertFalse(BannedEmailProvider.objects.filter(pk=provider.pk).exists()) + def tearDown(self): if os.path.isdir(settings.ZDS_APP['content']['repo_private_path']): shutil.rmtree(settings.ZDS_APP['content']['repo_private_path']) diff --git a/zds/member/views.py b/zds/member/views.py index ec718d045d..44b32ad4e4 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -25,7 +25,7 @@ from django.utils.translation import string_concat from django.utils.translation import ugettext_lazy as _ from django.views.decorators.http import require_POST -from django.views.generic import DetailView, ListView, UpdateView, CreateView, FormView +from django.views.generic import DetailView, UpdateView, CreateView, FormView from zds.forum.models import Topic, TopicRead from zds.gallery.forms import ImageAsAvatarForm @@ -648,8 +648,9 @@ class BannedEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSP .order_by('-date') -class MembersWithProviderList(LoginRequiredMixin, PermissionRequiredMixin, ListView): +class MembersWithProviderList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagingListView): permissions = ['member.change_bannedemailprovider'] + paginate_by = settings.ZDS_APP['member']['members_per_page'] model = User context_object_name = 'members' From 6d38beb01c21c01ceaa9e71e12e251f56184c125 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Tue, 9 May 2017 19:23:49 +0200 Subject: [PATCH 37/75] =?UTF-8?q?Nom=20et=20d=C3=A9pendance=20du=20fichier?= =?UTF-8?q?=20de=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...show_markdown_help.py => 0011_profile_show_markdown_help.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename zds/member/migrations/{0010_profile_show_markdown_help.py => 0011_profile_show_markdown_help.py} (87%) diff --git a/zds/member/migrations/0010_profile_show_markdown_help.py b/zds/member/migrations/0011_profile_show_markdown_help.py similarity index 87% rename from zds/member/migrations/0010_profile_show_markdown_help.py rename to zds/member/migrations/0011_profile_show_markdown_help.py index b8042a05bb..f349453975 100644 --- a/zds/member/migrations/0010_profile_show_markdown_help.py +++ b/zds/member/migrations/0011_profile_show_markdown_help.py @@ -7,7 +7,7 @@ class Migration(migrations.Migration): dependencies = [ - ('member', '0009_profile_show_staff_badge'), + ('member', '0010_bannedemailprovider_newemailprovider'), ] operations = [ From 3d8cf24381703178c2fde1d583659655e0906104 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Tue, 9 May 2017 19:47:22 +0200 Subject: [PATCH 38/75] Migrations interverties --- ...show_markdown_help.py => 0010_profile_show_markdown_help.py} | 2 +- ...provider.py => 0011_bannedemailprovider_newemailprovider.py} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename zds/member/migrations/{0011_profile_show_markdown_help.py => 0010_profile_show_markdown_help.py} (87%) rename zds/member/migrations/{0010_bannedemailprovider_newemailprovider.py => 0011_bannedemailprovider_newemailprovider.py} (97%) diff --git a/zds/member/migrations/0011_profile_show_markdown_help.py b/zds/member/migrations/0010_profile_show_markdown_help.py similarity index 87% rename from zds/member/migrations/0011_profile_show_markdown_help.py rename to zds/member/migrations/0010_profile_show_markdown_help.py index f349453975..b8042a05bb 100644 --- a/zds/member/migrations/0011_profile_show_markdown_help.py +++ b/zds/member/migrations/0010_profile_show_markdown_help.py @@ -7,7 +7,7 @@ class Migration(migrations.Migration): dependencies = [ - ('member', '0010_bannedemailprovider_newemailprovider'), + ('member', '0009_profile_show_staff_badge'), ] operations = [ diff --git a/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py b/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py similarity index 97% rename from zds/member/migrations/0010_bannedemailprovider_newemailprovider.py rename to zds/member/migrations/0011_bannedemailprovider_newemailprovider.py index bac24c4484..b9ffe4dc64 100644 --- a/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py +++ b/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py @@ -9,7 +9,7 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('member', '0009_profile_show_staff_badge'), + ('member', '0010_profile_show_markdown_help'), ] operations = [ From 7440b5a371b28adede5f466d458677fb48cdad70 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Thu, 11 May 2017 09:45:07 +0200 Subject: [PATCH 39/75] =?UTF-8?q?Migration=20des=20fournisseurs=20+=20fix?= =?UTF-8?q?=20quand=20l'extension=20n'est=20pas=20sp=C3=A9cifi=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- forbidden_email_providers.txt | 812 ----------------- .../add_banned_email_provider.html | 7 + .../banned_email_providers.html | 2 +- .../{ => settings}/members_with_provider.html | 0 .../{ => settings}/new_email_providers.html | 0 ...11_bannedemailprovider_newemailprovider.py | 824 ++++++++++++++++++ zds/member/validators.py | 7 +- zds/member/views.py | 16 +- zds/settings.py | 2 +- 9 files changed, 845 insertions(+), 825 deletions(-) delete mode 100644 forbidden_email_providers.txt rename templates/member/{ => settings}/add_banned_email_provider.html (76%) rename templates/member/{ => settings}/banned_email_providers.html (93%) rename templates/member/{ => settings}/members_with_provider.html (100%) rename templates/member/{ => settings}/new_email_providers.html (100%) diff --git a/forbidden_email_providers.txt b/forbidden_email_providers.txt deleted file mode 100644 index b6dc92aa8e..0000000000 --- a/forbidden_email_providers.txt +++ /dev/null @@ -1,812 +0,0 @@ -@0-mail.com -@0815.ru -@0clickemail.com -@0wnd.net -@0wnd.org -@10mail.org -@10minutemail. -@123-m.com -@123.com -@126.com -@139.com -@163.com -@1pad.de -@20mail. -@20minutemail.com -@20mm.in -@21cn.com -@2prong.com -@33mail.com -@3d-painting.com -@4warding. -@60minutemail.com -@6paq.com -@75hosting. -@7days-printing.com -@7tags.com -@99experts.com -@9ox.net -@a-bc.net -@abc.bg -@abusemail.de -@abv.bg -@abyssmail.com -@ac20mail.in -@acentri.com -@adamsnet.info -@adm1.me -@advantimo.com -@advertfast.com -@agedmail.com -@agendosa.com -@aichyna.com -@ajaxapp.net -@ak.mintemail.com -@amilegit.com -@amiri.net -@amiriindustries.com -@anappfor.com -@anappthat.com -@ano-mail.net -@anonbox.net -@anonymbox.com -@antichef. -@antifork.org -@antispam.de -@appixie.com -@armyspy.com -@atvclub.msk.ru -@baxomale.ht.cx -@beefmilk.com -@beefmilk.com -@berahe.info -@bi-dating.info -@bigmir.net -@bigstring.com -@binkmail.com -@bio-muesli.net -@bitmessage.ch -@bk.ru -@blackbox.trillianpro.com -@bladesmail.net -@bloatbox.com -@bob.ubx.se -@bobmail.info -@bodhi.lawlita.com -@bofthew.com -@bookee.com -@boxformail.in -@boximail.com -@boxtemp.com.br -@brefmail.com -@brennendesreich.de -@broadbandninja.com -@bsnow.net -@bspamfree.org -@buffemail.com -@bugmenot.com -@bumpymail.com -@bund.us -@burnthespam.info -@buyusedlibrarybooks.org -@byom.de -@c2.hu -@camcecil.com -@cash.com -@cashette. -@casualdx.com -@ccxt.info -@ce.mintemail.com -@cellurl.com -@centermail. -@chammy.info -@charklasers.com -@chcb.info -@cheatmail.de -@chogmail.com -@chong-mail. -@claeys.qc.to -@clixser.com -@clrmail.com -@cmail. -@cock.li -@coloccini.com.ar -@computerquip.com -@consumerriot.com -@cool.fr.nf -@correo.blogos.net -@corsa-tuning. -@cosmorph.com -@courriel.fr.nf -@courrieltemporaire.com -@crapmail.org -@crazespaces.pw -@curryworld.de -@cust.in -@cuvox.de -@cvs.in.th -@cx.de-a.org -@dacoolest.com -@dadasoft.com.mx -@daintly.com -@dandikmail.com -@dani.ml -@dataleak.info.tm -@dauer.info -@dayrep.com -@dbunker.com -@dcemail.com -@deadaddress.com -@deagot.com -@dealja.com -@deo-vindice -@despam.it -@devnullmail.com -@dfgh.net -@digit-labs.web.id -@digitalsanctuary.com -@dingbone.com -@dingbone.com -@dinkys.ws -@discardmail. -@discardmail.com -@disposableaddress.com -@disposableinbox.com -@dispose.it -@disposeamail.com -@disposemail. -@dispostable.com -@divermail.com -@dlemail.ru -@dm.w3internet.co.uk -@doc.biz.tm -@dodgeit. -@dodgeit.com -@dodgemail.de -@dodgit. -@domain141.com -@domforfb4.tk -@domozmail.com -@dontreg.com -@dontsendmespam.de -@dota.epicgamer.org -@dotmsg.com -@drdrb. -@droplar.com -@dropmail.me -@dudmail.com -@dump-email.info -@dumpyemail.com -@dunflimblag.mailexpire.com -@duskmail.com -@dw.now.im -@dx.ez.lv -@dx.sly.io -@e-mail. -@e-mail.com -@e4ward.com -@easy-trash-mail.com -@easytrashmail.com -@eco.wretch.twbbs.org -@eelmail.com -@einrot.com -@einrot.de -@email-jetable. -@email.cbes.net -@email.com -@email.net -@email60.com -@emailgo.de -@emailias.com -@emailinfive.com -@emailjetable. -@emaillime.com -@emailmiser.com -@emailsensei.com -@emailtemporar. -@emailtemporario. -@emailtemporario.com.br -@emailthe.net -@emailtmp. -@emailto.de -@emailwarden.com -@enraged-bl.tk -@envenve1e.com -@ephemail. -@epicgamer.org -@esa.thc.lv -@est.une.victime.ninja -@etranquil. -@europe.com -@evilninjapirates.com -@example.com -@explodemail.com -@eyepaste.com -@faic.tk -@fakeinbox.com -@fakeinformation.com -@fakemail.com -@fakemail.fr -@fanaticars.info -@fantasymail.de -@fastacura.com -@fatflap.com -@faza.ru -@fdfdsfds.com -@fightallspam.com -@filzmail.com -@find-love.info -@fizmail.com -@fleckens.hu -@flemail.ru -@flurred.com -@flyspam.com -@for-fun.info -@foteret.info -@fr33mail.info -@fractum.hol.es -@frapmail.com -@freefreemail.info -@freenet.de -@freestuffo1. -@freestuffo2. -@freestuffo3. -@freestuffo4. -@friendlymail. -@fromru.com -@front14.org -@fuckingduh.com -@fudgerub.com -@fudgerub.com -@gametheorylabs.com -@garliclife.com -@gawab.com -@geer4.mooo.com -@get1mail.com -@get2mail.fr -@getairmail.com -@getmails.eu -@getonemail. -@ghosttexter.de -@girlsundertheinfluence.com -@gishpuppy.com -@gnoia.org -@go.irc.so -@goemailgo.com -@gold2world.biz -@gotmail. -@gotti.otherinbox.com -@gowikibooks.com -@gowikicampus.com -@gowikicars.com -@gowikifilms.com -@gowikigames.com -@gowikimusic.com -@gowikinetwork.com -@gowikitravel.com -@gowikitv.com -@grandmamail.com -@grandmasmail.com -@great-host.in -@grifon.info -@grr.la -@gsrv.co.uk -@guerillamail. -@guerrillamail. -@guerrillamailblock. -@gustr.com -@h1ch3r.net -@hacccc.com -@hacker1.com.br -@haltospam.com -@haqed.com -@haqued.com -@harakirimail.com -@herp.in -@hidzz.com -@hintz.org -@hochsitze.com -@hotpop.com -@hulapla.de -@humn.ws.gy -@hushmail.com -@idan.be -@ieatspam.eu -@ieatspam.info -@iespana.es -@ignorelist.com -@ihateyoualot.info -@iiserk.net -@imails.info -@imgof.com -@inbox.ru -@inboxclean. -@incognitomail. -@instant-mail.de -@ipoo.org -@irish2me.com -@isaichkin.ru -@isuisse.com -@it.sackler.net -@iwi.net -@jetable. -@jnxjn.com -@jourrapide.com -@jsrsolutions.com -@junk.trillianpro.com -@junk1e.com -@kasmail.com -@kaspop.com -@kkll.cu.cc -@klassmaster.com -@kloap.com -@klzlk.com -@korsun.pp.ru -@kulturbetrieb.info -@kurzepost.de -@landmail.co -@lastmail. -@lavabit.com -@lekovic.ca -@letthemeatspam.com -@lhsdv.com -@lichtisten.com -@lifebyfood.com -@link2mail. -@link2mail.net -@linuxx.org -@linxlunx.info -@list.ru -@litedrop.com -@lookugly.com -@lopl.co.cc -@lovemeleaveme.com -@lr78.com -@lroid.com -@m4ilweb.info -@ma1l.bij.pl -@maboard.com -@mail-filter.com -@mail-gratuit.com -@mail-temporaire. -@mail.by -@mail.mezimages.net -@mail.ru -@mail114.net -@mail15.com -@mail15.fr -@mail333.com -@mail4trash.com -@mailbidon.com -@mailbucket.org -@mailcatch.com -@maildx.com -@maileater.com -@mailed.ro -@mailexpire.com -@mailfs.com -@mailguard.me -@mailhazard.com -@mailin8r.com -@mailinater.com -@mailinator. -@mailinator2. -@mailincubator.com -@mailismagic.com -@mailme.crabdance.com -@mailme.lv -@mailmetrash.com -@mailmoat.com -@mailnator. -@mailnesia.com -@mailnull.com -@mailquack.com -@mailscrap.com -@mailtemporaire.com -@mailtemporaire.fr -@mailtothis.com -@mailzi.ru -@mailzilla. -@makemetheking.com -@manybrain.com -@masterhost.ru -@mbx.cc -@mega.zik.dj -@meltmail.com -@messagebeamer.de -@mierdamail.com -@migmail.pl -@migumail.com -@mintemail.com -@misena.edu.co -@mobileninja.co.uk -@moburl.com -@mohmal.com -@moncourrier.fr.nf -@monemail.fr.nf -@monmail.fr.nf -@monumentmail.com -@mor19.uu.gl -@mouly.com.ar -@moyareklama.ru -@mrbox.root.sx -@msk.su -@mt2009.com -@mt2014.com -@muell.email -@muuh.info -@mx0.wwwnew.eu -@my.efxs.ca -@my10minutemail.com -@mybox.root.sx -@mycleaninbox.net -@myemailboxy.com -@mymail-in.net -@mypacks.net -@mypartyclip.de -@myspaceinc. -@myspacepimpedup.com -@mytemp.email -@mytempemail.com -@mytrashmail.com -@myxost.com -@national.shitposting.agency -@naver.com -@ne-quid-nimis.info -@nepwk.com -@nervmich.net -@nervtmich.net -@netmails.net -@netzidiot.de -@neverbox.com -@nice-4u.com -@nikvdp.com -@nil-admirari.info -@no-spam. -@no-spam.hu -@nobulk.com -@noclickemail.com -@nogmailspam.info -@nomail.xl.cx -@nomail2me.com -@nospam. -@nospam.ze.tc -@nospam4. -@nospamfor. -@nospamthanks.info -@notmailinator.com -@novoemail.homenet.org -@nowhere.org -@nowmymail.com -@nowonder.homenet.org -@nowwhat.linuxd.org -@nurfuerspam.de -@nwldx.com -@objectmail.com -@obobbo.com -@octivian.com -@one.it -@oneoffemail.com -@onetime.email -@onewaymail.com -@oopi.org -@oos.tw -@ordinaryamerican.net -@otherinbox.com -@ourklips.com -@ove.ali.com.pk -@owlpic.com -@p0ns.org -@paplease.com -@paschke.org -@paukner.org -@pcusers.otherinbox.com -@pecdo.com -@pedco.com -@pepbot.com -@perlpowered.com -@pimpedupmyspace.com -@pisem.net -@plsmail.us.to -@po.bot.nu -@pochta.ru -@poczta.onet.pl -@politikerclub.de -@pookmail.com -@porn.com -@pornoroxx.net -@portsaid.cc -@prescrip.pl -@privacy.net -@privy-mail.com -@protocultura.net -@proxymail.eu -@prtnx.com -@puk.us.to -@punkass.com -@putthisinyourspamdatabase.com -@pwn.linuxx.org -@pwrby.com -@qarea.com -@qasti.com -@qia.bep.co.id -@qisdo.com -@qisoa.com -@qlfg.com -@qq.com -@quasti.com -@quickinbox.com -@radiku.ye.vc -@rambler.ru -@ranftl.org -@rcpt.at -@reallymymail.com -@recode.me -@recursor.net -@reddementes.net -@redthumb.info.tm -@regbypass. -@rev.vci.si -@rhyta.com -@rklips.com -@rmqkr.net -@roshankarki.com.np -@royal.net -@rppkn.com -@rr.ccs.pl -@rtrtr.com -@s0ny.net -@safe-mail.net -@safetymail.info -@safetypost.de -@sales.trillianpro.com -@samo.ohi.tw -@sandelf.de -@saynotospams.com -@schafmail.de -@seco.sne.jp -@secret.shop.tm -@selfdestructingmail.com -@sempaktools.us.to -@sendspamhere.com -@sharklasers.com -@shiftmail.com -@shit.trillianpro.com -@shitmail. -@shitware. -@shokri.net -@shop.tm -@shop.tn -@shortmail.net -@shotmail.ru -@sibmail.com -@sify.com -@sija.pl -@sinnlos-mail.de -@siteposter.net -@sixohquad.com -@skeefmail.com -@skim.com -@slopsbox.com -@smeh.info -@smellfear.com -@smellfear.com -@snakemail.com -@sneakemail.com -@snkmail.com -@sofasurfer.ch -@sofort-mail.de -@sogetthis.com -@somany.ignorelist.com -@soodonims.com -@space-elephant.com -@spam. -@spam.la -@spam4. -@spam4.me -@spamarrest. -@spamavert. -@spambob. -@spambooger.com -@spambox. -@spambox.us -@spamcannon. -@spamcero.com -@spamcorptastic.com -@spamday.com -@spameater.org -@spamex.com -@spamfree. -@spamfree24. -@spamfree24.com -@spamfree24.net -@spamfree24.org -@spamgoes.in -@spamgourmet. -@spamgourmet.com -@spamh0le.com -@spamherelots.com -@spamhereplease.com -@spamhole.com -@spamify.com -@spaminator.de -@spamkill. -@spaml. -@spammotel.com -@spamobox.com -@spamsalad.in -@spamspot.com -@spamthis.co.uk -@spamthisplease.com -@spamtrail.com -@spamtroll.net -@speed.1s.fr -@spikio.com -@spoofmail.de -@squizzy.de -@sr.ro.lt -@startkeys.com -@stinkefinger.net -@streetwisemail.com -@stuffmail.de -@supergreatmail.com -@superrito.com -@superstachel.de -@suremail.info -@sysnet.org.pk -@tafmail.com -@tagyourself.com -@talkinator.com -@tapchicuoihoi.com -@techie.com -@teewars.org -@tele-vision.info -@teleworm.com -@teleworm.us -@temp-mail.org -@temp.emeraldwebmail.com -@tempalias.com -@tempe-mail.com -@tempemail. -@tempemail.net -@tempemail.net -@tempinbox.co.uk -@tempinbox.com -@tempmail.it -@tempmaildemo.com -@tempmailer.com -@tempomail. -@temporarily.de -@temporaryemail. -@temporaryinbox. -@temporaryinbox.com -@tempthe.net -@test5566.strangled.net -@thailaaa.org.ua -@thanksnospam.info -@thankyou2010.com -@thecannabishunter.com -@thedens.org -@theins4ne.net -@thisisnotmyrealemail.com -@thrma.com -@throam.com -@throwawayemailaddress.com -@throwawaymail.com -@tilien.com -@tittbit.in -@tmail.com -@tmailinator.com -@tokenmail.de -@tormail.org -@torry.multiservice.ru -@tradedoubling.co.uk -@tradermail.info -@trash-amil. -@trash-mail. -@trash-mail.com -@trash-mail.de -@trash2009. -@trash2010. -@trash2011. -@trashdevil.com -@trashdevil.de -@trashmail. -@trashmailer. -@trashymail. -@travelwith.spacetechnology.net -@trbvm.com -@trickmail.net -@trickmail.net6 -@trillianpro.com -@trollope.za.net -@turual.com -@tut.by -@twilightparadox.com -@tyldd.com -@ubismail.net -@uggsrock.com -@ukr.net -@umail.net -@upal.se -@upliftnow.com -@uplipht.com -@uroid.com -@usa.com -@users.1go.dk -@valemail.net -@veryrealemail.com -@vidchart.com -@viditag.com -@viewcastmedia.com -@viewcastmedia.net -@viewcastmedia.org -@viona.ml -@vkcode.ru -@vomoto.com -@vp.ycare.de -@vubby.com -@vxaz.com -@walala.org -@walkmail.ru -@want.javafaq.nu -@webemail.me -@webm4il.info -@weg-werf-email.de -@wegwerf-email-addressen.de -@wegwerf-emails.de -@wegwerfadresse.de -@wegwerfemail.de -@wegwerfmail. -@weibo.10086.cn -@welcome.twilightparadox.com -@wetrainbayarea.com -@wetrainbayarea.org -@wezel.ch -@wezel.info -@wh4f.com -@wh4f.org -@whatiaas.com -@whyspam.me -@wickmail.net -@willhackforfood.biz -@willselfdestruct.com -@winemaven.info -@winter.org -@wollan.info -@wollmann.org -@wovz.cu.cc -@wronghead.com -@wuzup.net -@wuzupmail.net -@x.trillianpro.com -@xagloo.com -@xardas.eu -@xing886.uu.gl -@xmail.com -@xoxy.net -@xww.ro -@xyzfree.net -@yahoo.com.ph -@yahoo.com.vn -@yandex.ru -@yeah.net -@yert.ye.vc -@yet.eva.hk -@yeuthuong.org -@yhg.biz -@yis.vr.lt -@yogamaven.com -@yomail.info -@yopmail. -@yopmail.netmailnesia.com -@you.loc.im -@ypmail. -@yufz.com -@yuurok.com -@za.com -@ze.gally.jp -@zetmail.com -@zippymail.info -@zoemail.net -@zomg.info \ No newline at end of file diff --git a/templates/member/add_banned_email_provider.html b/templates/member/settings/add_banned_email_provider.html similarity index 76% rename from templates/member/add_banned_email_provider.html rename to templates/member/settings/add_banned_email_provider.html index 876027031b..907c34ce7c 100644 --- a/templates/member/add_banned_email_provider.html +++ b/templates/member/settings/add_banned_email_provider.html @@ -29,6 +29,13 @@ {% block content %} +

    {% trans "Vous pouvez utiliser :" %}

    + +
      +
    • {% trans "Un nom de domaine complet (« fournisseur.tld »)." %}
    • +
    • {% trans "Un nom de domaine sans extension (« fournisseur. »), auquel cas elle seront toutes concernées." %}
    • +
    +
    {% crispy form %}
    diff --git a/templates/member/banned_email_providers.html b/templates/member/settings/banned_email_providers.html similarity index 93% rename from templates/member/banned_email_providers.html rename to templates/member/settings/banned_email_providers.html index c46f32cff3..99e7f993ef 100644 --- a/templates/member/banned_email_providers.html +++ b/templates/member/settings/banned_email_providers.html @@ -46,8 +46,8 @@
    {% csrf_token %} + {% trans "Comptes correspondants" %} - {% trans "Comptes avec ce fournisseur" %} {% endfor %} diff --git a/templates/member/members_with_provider.html b/templates/member/settings/members_with_provider.html similarity index 100% rename from templates/member/members_with_provider.html rename to templates/member/settings/members_with_provider.html diff --git a/templates/member/new_email_providers.html b/templates/member/settings/new_email_providers.html similarity index 100% rename from templates/member/new_email_providers.html rename to templates/member/settings/new_email_providers.html diff --git a/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py b/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py index b9ffe4dc64..698e31c919 100644 --- a/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py +++ b/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py @@ -3,6 +3,829 @@ from django.db import migrations, models from django.conf import settings +from django.contrib.auth.models import User + +from zds.member.models import BannedEmailProvider + + +def forwards_func(apps, schema_editor): + # Import banned providers if there is a bot account + providers = [ + '0-mail.com', + '0815.ru', + '0clickemail.com', + '0wnd.net', + '0wnd.org', + '10mail.org', + '10minutemail.', + '123-m.com', + '123.com', + '126.com', + '139.com', + '163.com', + '1pad.de', + '20mail.', + '20minutemail.com', + '20mm.in', + '21cn.com', + '2prong.com', + '33mail.com', + '3d-painting.com', + '4warding.', + '60minutemail.com', + '6paq.com', + '75hosting.', + '7days-printing.com', + '7tags.com', + '99experts.com', + '9ox.net', + 'a-bc.net', + 'abc.bg', + 'abusemail.de', + 'abv.bg', + 'abyssmail.com', + 'ac20mail.in', + 'acentri.com', + 'adamsnet.info', + 'adm1.me', + 'advantimo.com', + 'advertfast.com', + 'agedmail.com', + 'agendosa.com', + 'aichyna.com', + 'ajaxapp.net', + 'ak.mintemail.com', + 'amilegit.com', + 'amiri.net', + 'amiriindustries.com', + 'anappfor.com', + 'anappthat.com', + 'ano-mail.net', + 'anonbox.net', + 'anonymbox.com', + 'antichef.', + 'antifork.org', + 'antispam.de', + 'appixie.com', + 'armyspy.com', + 'atvclub.msk.ru', + 'baxomale.ht.cx', + 'beefmilk.com', + 'berahe.info', + 'bi-dating.info', + 'bigmir.net', + 'bigstring.com', + 'binkmail.com', + 'bio-muesli.net', + 'bitmessage.ch', + 'bk.ru', + 'blackbox.trillianpro.com', + 'bladesmail.net', + 'bloatbox.com', + 'bob.ubx.se', + 'bobmail.info', + 'bodhi.lawlita.com', + 'bofthew.com', + 'bookee.com', + 'boxformail.in', + 'boximail.com', + 'boxtemp.com.br', + 'brefmail.com', + 'brennendesreich.de', + 'broadbandninja.com', + 'bsnow.net', + 'bspamfree.org', + 'buffemail.com', + 'bugmenot.com', + 'bumpymail.com', + 'bund.us', + 'burnthespam.info', + 'buyusedlibrarybooks.org', + 'byom.de', + 'c2.hu', + 'camcecil.com', + 'cash.com', + 'cashette.', + 'casualdx.com', + 'ccxt.info', + 'ce.mintemail.com', + 'cellurl.com', + 'centermail.', + 'chammy.info', + 'charklasers.com', + 'chcb.info', + 'cheatmail.de', + 'chogmail.com', + 'chong-mail.', + 'claeys.qc.to', + 'clixser.com', + 'clrmail.com', + 'cmail.', + 'cock.li', + 'coloccini.com.ar', + 'computerquip.com', + 'consumerriot.com', + 'cool.fr.nf', + 'correo.blogos.net', + 'corsa-tuning.', + 'cosmorph.com', + 'courriel.fr.nf', + 'courrieltemporaire.com', + 'crapmail.org', + 'crazespaces.pw', + 'curryworld.de', + 'cust.in', + 'cuvox.de', + 'cvs.in.th', + 'cx.de-a.org', + 'dacoolest.com', + 'dadasoft.com.mx', + 'daintly.com', + 'dandikmail.com', + 'dani.ml', + 'dataleak.info.tm', + 'dauer.info', + 'dayrep.com', + 'dbunker.com', + 'dcemail.com', + 'deadaddress.com', + 'deagot.com', + 'dealja.com', + 'deo-vindice', + 'despam.it', + 'devnullmail.com', + 'dfgh.net', + 'digit-labs.web.id', + 'digitalsanctuary.com', + 'dingbone.com', + 'dinkys.ws', + 'discardmail.', + 'discardmail.com', + 'disposableaddress.com', + 'disposableinbox.com', + 'dispose.it', + 'disposeamail.com', + 'disposemail.', + 'dispostable.com', + 'divermail.com', + 'dlemail.ru', + 'dm.w3internet.co.uk', + 'doc.biz.tm', + 'dodgeit.', + 'dodgeit.com', + 'dodgemail.de', + 'dodgit.', + 'domain141.com', + 'domforfb4.tk', + 'domozmail.com', + 'dontreg.com', + 'dontsendmespam.de', + 'dota.epicgamer.org', + 'dotmsg.com', + 'drdrb.', + 'droplar.com', + 'dropmail.me', + 'dudmail.com', + 'dump-email.info', + 'dumpyemail.com', + 'dunflimblag.mailexpire.com', + 'duskmail.com', + 'dw.now.im', + 'dx.ez.lv', + 'dx.sly.io', + 'e-mail.', + 'e-mail.com', + 'e4ward.com', + 'easy-trash-mail.com', + 'easytrashmail.com', + 'eco.wretch.twbbs.org', + 'eelmail.com', + 'einrot.com', + 'einrot.de', + 'email-jetable.', + 'email.cbes.net', + 'email.com', + 'email.net', + 'email60.com', + 'emailgo.de', + 'emailias.com', + 'emailinfive.com', + 'emailjetable.', + 'emaillime.com', + 'emailmiser.com', + 'emailsensei.com', + 'emailtemporar.', + 'emailtemporario.', + 'emailtemporario.com.br', + 'emailthe.net', + 'emailtmp.', + 'emailto.de', + 'emailwarden.com', + 'enraged-bl.tk', + 'envenve1e.com', + 'ephemail.', + 'epicgamer.org', + 'esa.thc.lv', + 'est.une.victime.ninja', + 'etranquil.', + 'europe.com', + 'evilninjapirates.com', + 'example.com', + 'explodemail.com', + 'eyepaste.com', + 'faic.tk', + 'fakeinbox.com', + 'fakeinformation.com', + 'fakemail.com', + 'fakemail.fr', + 'fanaticars.info', + 'fantasymail.de', + 'fastacura.com', + 'fatflap.com', + 'faza.ru ', + 'fdfdsfds.com', + 'fightallspam.com', + 'filzmail.com', + 'find-love.info', + 'fizmail.com', + 'fleckens.hu', + 'flemail.ru', + 'flurred.com', + 'flyspam.com', + 'for-fun.info', + 'foteret.info', + 'fr33mail.info', + 'fractum.hol.es', + 'frapmail.com', + 'freefreemail.info', + 'freenet.de', + 'freestuffo1.', + 'freestuffo2.', + 'freestuffo3.', + 'freestuffo4.', + 'friendlymail.', + 'fromru.com', + 'front14.org', + 'fuckingduh.com', + 'fudgerub.com', + 'gametheorylabs.com', + 'garliclife.com', + 'gawab.com', + 'geer4.mooo.com', + 'get1mail.com', + 'get2mail.fr', + 'getairmail.com', + 'getmails.eu', + 'getonemail.', + 'ghosttexter.de', + 'girlsundertheinfluence.com', + 'gishpuppy.com', + 'gnoia.org', + 'go.irc.so', + 'goemailgo.com', + 'gold2world.biz', + 'gotmail.', + 'gotti.otherinbox.com', + 'gowikibooks.com', + 'gowikicampus.com', + 'gowikicars.com', + 'gowikifilms.com', + 'gowikigames.com', + 'gowikimusic.com', + 'gowikinetwork.com', + 'gowikitravel.com', + 'gowikitv.com', + 'grandmamail.com', + 'grandmasmail.com', + 'great-host.in', + 'grifon.info', + 'grr.la', + 'gsrv.co.uk', + 'guerillamail.', + 'guerrillamail.', + 'guerrillamailblock.', + 'gustr.com', + 'h1ch3r.net', + 'hacccc.com', + 'hacker1.com.br', + 'haltospam.com', + 'haqed.com', + 'haqued.com', + 'harakirimail.com', + 'herp.in', + 'hidzz.com', + 'hintz.org', + 'hochsitze.com', + 'hotpop.com', + 'hulapla.de', + 'humn.ws.gy', + 'hushmail.com', + 'idan.be', + 'ieatspam.eu', + 'ieatspam.info', + 'iespana.es', + 'ignorelist.com', + 'ihateyoualot.info', + 'iiserk.net', + 'imails.info', + 'imgof.com', + 'inbox.ru', + 'inboxclean.', + 'incognitomail.', + 'instant-mail.de', + 'ipoo.org', + 'irish2me.com', + 'isaichkin.ru', + 'isuisse.com', + 'it.sackler.net', + 'iwi.net', + 'jetable.', + 'jnxjn.com', + 'jourrapide.com', + 'jsrsolutions.com', + 'junk.trillianpro.com', + 'junk1e.com', + 'kasmail.com', + 'kaspop.com', + 'kkll.cu.cc', + 'klassmaster.com', + 'kloap.com', + 'klzlk.com', + 'korsun.pp.ru', + 'kulturbetrieb.info', + 'kurzepost.de', + 'landmail.co', + 'lastmail.', + 'lavabit.com', + 'lekovic.ca', + 'letthemeatspam.com', + 'lhsdv.com', + 'lichtisten.com', + 'lifebyfood.com', + 'link2mail.', + 'link2mail.net', + 'linuxx.org', + 'linxlunx.info', + 'list.ru', + 'litedrop.com', + 'lookugly.com', + 'lopl.co.cc', + 'lovemeleaveme.com', + 'lr78.com', + 'lroid.com', + 'm4ilweb.info', + 'ma1l.bij.pl', + 'maboard.com', + 'mail-filter.com', + 'mail-gratuit.com', + 'mail-temporaire.', + 'mail.by', + 'mail.mezimages.net', + 'mail.ru', + 'mail114.net', + 'mail15.com', + 'mail15.fr', + 'mail333.com', + 'mail4trash.com', + 'mailbidon.com', + 'mailbucket.org', + 'mailcatch.com', + 'maildx.com', + 'maileater.com', + 'mailed.ro', + 'mailexpire.com', + 'mailfs.com', + 'mailguard.me', + 'mailhazard.com', + 'mailin8r.com', + 'mailinater.com', + 'mailinator.', + 'mailinator2.', + 'mailincubator.com', + 'mailismagic.com', + 'mailme.crabdance.com', + 'mailme.lv', + 'mailmetrash.com', + 'mailmoat.com', + 'mailnator.', + 'mailnesia.com', + 'mailnull.com', + 'mailquack.com', + 'mailscrap.com', + 'mailtemporaire.com', + 'mailtemporaire.fr', + 'mailtothis.com', + 'mailzi.ru', + 'mailzilla.', + 'makemetheking.com', + 'manybrain.com', + 'masterhost.ru', + 'mbx.cc', + 'mega.zik.dj', + 'meltmail.com', + 'messagebeamer.de', + 'mierdamail.com', + 'migmail.pl', + 'migumail.com', + 'mintemail.com', + 'misena.edu.co', + 'mobileninja.co.uk', + 'moburl.com', + 'mohmal.com', + 'moncourrier.fr.nf', + 'monemail.fr.nf', + 'monmail.fr.nf', + 'monumentmail.com', + 'mor19.uu.gl', + 'mouly.com.ar', + 'moyareklama.ru', + 'mrbox.root.sx', + 'msk.su', + 'mt2009.com', + 'mt2014.com', + 'muell.email', + 'muuh.info', + 'mx0.wwwnew.eu', + 'my.efxs.ca', + 'my10minutemail.com', + 'mybox.root.sx', + 'mycleaninbox.net', + 'myemailboxy.com', + 'mymail-in.net', + 'mypacks.net', + 'mypartyclip.de', + 'myspaceinc.', + 'myspacepimpedup.com', + 'mytemp.email', + 'mytempemail.com', + 'mytrashmail.com', + 'myxost.com', + 'national.shitposting.agency', + 'naver.com', + 'ne-quid-nimis.info', + 'nepwk.com', + 'nervmich.net', + 'nervtmich.net', + 'netmails.net', + 'netzidiot.de', + 'neverbox.com', + 'nice-4u.com', + 'nikvdp.com', + 'nil-admirari.info', + 'no-spam.', + 'no-spam.hu', + 'nobulk.com', + 'noclickemail.com', + 'nogmailspam.info', + 'nomail.xl.cx', + 'nomail2me.com', + 'nospam.', + 'nospam.ze.tc', + 'nospam4.', + 'nospamfor.', + 'nospamthanks.info', + 'notmailinator.com', + 'novoemail.homenet.org', + 'nowhere.org', + 'nowmymail.com', + 'nowonder.homenet.org', + 'nowwhat.linuxd.org', + 'nurfuerspam.de', + 'nwldx.com', + 'objectmail.com', + 'obobbo.com', + 'octivian.com', + 'one.it', + 'oneoffemail.com', + 'onetime.email', + 'onewaymail.com', + 'oopi.org', + 'oos.tw', + 'ordinaryamerican.net', + 'otherinbox.com', + 'ourklips.com', + 'ove.ali.com.pk', + 'owlpic.com', + 'p0ns.org', + 'paplease.com', + 'paschke.org', + 'paukner.org', + 'pcusers.otherinbox.com', + 'pecdo.com', + 'pedco.com', + 'pepbot.com', + 'perlpowered.com', + 'pimpedupmyspace.com', + 'pisem.net', + 'plsmail.us.to', + 'po.bot.nu', + 'pochta.ru', + 'poczta.onet.pl', + 'politikerclub.de', + 'pookmail.com', + 'porn.com', + 'pornoroxx.net', + 'portsaid.cc', + 'prescrip.pl', + 'privacy.net', + 'privy-mail.com', + 'protocultura.net', + 'proxymail.eu', + 'prtnx.com', + 'puk.us.to', + 'punkass.com', + 'putthisinyourspamdatabase.com', + 'pwn.linuxx.org', + 'pwrby.com', + 'qarea.com', + 'qasti.com', + 'qia.bep.co.id', + 'qisdo.com', + 'qisoa.com', + 'qlfg.com', + 'qq.com', + 'quasti.com', + 'quickinbox.com', + 'radiku.ye.vc', + 'rambler.ru', + 'ranftl.org', + 'rcpt.at', + 'reallymymail.com', + 'recode.me', + 'recursor.net', + 'reddementes.net', + 'redthumb.info.tm', + 'regbypass.', + 'rev.vci.si', + 'rhyta.com', + 'rklips.com', + 'rmqkr.net', + 'roshankarki.com.np', + 'royal.net', + 'rppkn.com', + 'rr.ccs.pl', + 'rtrtr.com', + 's0ny.net', + 'safe-mail.net', + 'safetymail.info', + 'safetypost.de', + 'sales.trillianpro.com', + 'samo.ohi.tw', + 'sandelf.de', + 'saynotospams.com', + 'schafmail.de', + 'seco.sne.jp', + 'secret.shop.tm', + 'selfdestructingmail.com', + 'sempaktools.us.to', + 'sendspamhere.com', + 'sharklasers.com', + 'shiftmail.com', + 'shit.trillianpro.com', + 'shitmail.', + 'shitware.', + 'shokri.net', + 'shop.tm', + 'shop.tn', + 'shortmail.net', + 'shotmail.ru', + 'sibmail.com', + 'sify.com', + 'sija.pl', + 'sinnlos-mail.de', + 'siteposter.net', + 'sixohquad.com', + 'skeefmail.com', + 'skim.com', + 'slopsbox.com', + 'smeh.info', + 'smellfear.com', + 'snakemail.com', + 'sneakemail.com', + 'snkmail.com', + 'sofasurfer.ch', + 'sofort-mail.de', + 'sogetthis.com', + 'somany.ignorelist.com', + 'soodonims.com', + 'space-elephant.com', + 'spam.', + 'spam.la', + 'spam4.', + 'spam4.me', + 'spamarrest.', + 'spamavert.', + 'spambob.', + 'spambooger.com', + 'spambox.', + 'spambox.us', + 'spamcannon.', + 'spamcero.com', + 'spamcorptastic.com', + 'spamday.com', + 'spameater.org', + 'spamex.com', + 'spamfree.', + 'spamfree24.', + 'spamfree24.com', + 'spamfree24.net', + 'spamfree24.org', + 'spamgoes.in', + 'spamgourmet.', + 'spamgourmet.com', + 'spamh0le.com', + 'spamherelots.com', + 'spamhereplease.com', + 'spamhole.com', + 'spamify.com', + 'spaminator.de', + 'spamkill.', + 'spaml.', + 'spammotel.com', + 'spamobox.com', + 'spamsalad.in', + 'spamspot.com', + 'spamthis.co.uk', + 'spamthisplease.com', + 'spamtrail.com', + 'spamtroll.net', + 'speed.1s.fr', + 'spikio.com', + 'spoofmail.de', + 'squizzy.de', + 'sr.ro.lt', + 'startkeys.com', + 'stinkefinger.net', + 'streetwisemail.com', + 'stuffmail.de', + 'supergreatmail.com', + 'superrito.com', + 'superstachel.de', + 'suremail.info', + 'sysnet.org.pk', + 'tafmail.com', + 'tagyourself.com', + 'talkinator.com', + 'tapchicuoihoi.com', + 'techie.com', + 'teewars.org', + 'tele-vision.info', + 'teleworm.com', + 'teleworm.us', + 'temp-mail.org', + 'temp.emeraldwebmail.com', + 'tempalias.com', + 'tempe-mail.com', + 'tempemail.', + 'tempemail.net', + 'tempinbox.co.uk', + 'tempinbox.com', + 'tempmail.it', + 'tempmaildemo.com', + 'tempmailer.com', + 'tempomail.', + 'temporarily.de', + 'temporaryemail.', + 'temporaryinbox.', + 'temporaryinbox.com', + 'tempthe.net', + 'test5566.strangled.net', + 'thailaaa.org.ua', + 'thanksnospam.info', + 'thankyou2010.com', + 'thecannabishunter.com', + 'thedens.org', + 'theins4ne.net', + 'thisisnotmyrealemail.com', + 'thrma.com', + 'throam.com', + 'throwawayemailaddress.com', + 'throwawaymail.com', + 'tilien.com', + 'tittbit.in', + 'tmail.com', + 'tmailinator.com', + 'tokenmail.de', + 'tormail.org', + 'torry.multiservice.ru', + 'tradedoubling.co.uk', + 'tradermail.info', + 'trash-amil.', + 'trash-mail.', + 'trash-mail.com', + 'trash-mail.de', + 'trash2009.', + 'trash2010.', + 'trash2011.', + 'trashdevil.com', + 'trashdevil.de', + 'trashmail.', + 'trashmailer.', + 'trashymail.', + 'travelwith.spacetechnology.net', + 'trbvm.com', + 'trickmail.net', + 'trickmail.net6', + 'trillianpro.com', + 'trollope.za.net', + 'turual.com', + 'tut.by', + 'twilightparadox.com', + 'tyldd.com', + 'ubismail.net', + 'uggsrock.com', + 'ukr.net', + 'umail.net', + 'upal.se', + 'upliftnow.com', + 'uplipht.com', + 'uroid.com', + 'usa.com', + 'users.1go.dk', + 'valemail.net', + 'veryrealemail.com', + 'vidchart.com', + 'viditag.com', + 'viewcastmedia.com', + 'viewcastmedia.net', + 'viewcastmedia.org', + 'viona.ml', + 'vkcode.ru', + 'vomoto.com', + 'vp.ycare.de', + 'vubby.com', + 'vxaz.com', + 'walala.org', + 'walkmail.ru', + 'want.javafaq.nu', + 'webemail.me', + 'webm4il.info', + 'weg-werf-email.de', + 'wegwerf-email-addressen.de', + 'wegwerf-emails.de', + 'wegwerfadresse.de', + 'wegwerfemail.de', + 'wegwerfmail.', + 'weibo.10086.cn', + 'welcome.twilightparadox.com', + 'wetrainbayarea.com', + 'wetrainbayarea.org', + 'wezel.ch', + 'wezel.info', + 'wh4f.com', + 'wh4f.org', + 'whatiaas.com', + 'whyspam.me', + 'wickmail.net', + 'willhackforfood.biz', + 'willselfdestruct.com', + 'winemaven.info', + 'winter.org', + 'wollan.info', + 'wollmann.org', + 'wovz.cu.cc', + 'wronghead.com', + 'wuzup.net', + 'wuzupmail.net', + 'x.trillianpro.com', + 'xagloo.com', + 'xardas.eu', + 'xing886.uu.gl', + 'xmail.com', + 'xoxy.net', + 'xww.ro', + 'xyzfree.net', + 'yahoo.com.ph', + 'yahoo.com.vn', + 'yandex.ru', + 'yeah.net', + 'yert.ye.vc', + 'yet.eva.hk', + 'yeuthuong.org', + 'yhg.biz', + 'yis.vr.lt', + 'yogamaven.com', + 'yomail.info', + 'yopmail.', + 'yopmail.netmailnesia.com', + 'you.loc.im', + 'ypmail.', + 'yufz.com', + 'yuurok.com', + 'za.com', + 'ze.gally.jp', + 'zetmail.com', + 'zippymail.info', + 'zoemail.net', + 'zomg.info', + ] + + try: + bot = User.objects.get(username=settings.ZDS_APP['member']['bot_account']) + bans = [BannedEmailProvider(provider=p, moderator=bot) for p in providers] + BannedEmailProvider.objects.bulk_create(bans) + except User.DoesNotExist: + pass class Migration(migrations.Migration): @@ -40,4 +863,5 @@ class Migration(migrations.Migration): 'verbose_name_plural': 'Nouveaux fournisseurs', }, ), + migrations.RunPython(forwards_func), ] diff --git a/zds/member/validators.py b/zds/member/validators.py index 310a3a107d..f200027425 100644 --- a/zds/member/validators.py +++ b/zds/member/validators.py @@ -46,9 +46,10 @@ def __call__(self, value, check_username_available=True): raise ValidationError(self.message, code=self.code) # check if provider is blacklisted - provider = re.findall(r'@(.+)', value)[0] - if BannedEmailProvider.objects.filter(provider=provider).exists(): - raise ValidationError(_(u'Ce fournisseur ne peut pas être utilisé.'), code=self.code) + blacklist = BannedEmailProvider.objects.values_list('provider', flat=True) + for provider in blacklist: + if '@{}'.format(provider) in value: + raise ValidationError(_(u'Ce fournisseur ne peut pas être utilisé.'), code=self.code) # check if email is used by another user user_count = User.objects.filter(email=value).count() diff --git a/zds/member/views.py b/zds/member/views.py index 44b32ad4e4..52e8278c35 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -321,7 +321,7 @@ def update_profile(self, profile, form): profile.user.username = new_username if new_email and new_email != previous_email: profile.user.email = new_email - # create an alert for staff if it's a new provider + # create an alert for the staff if it's a new provider provider = re.findall(r'@(.+)', new_email)[0] if not NewEmailProvider.objects.filter(provider=provider).exists() \ and not User.objects.filter(email__endswith='@{}'.format(provider)) \ @@ -612,7 +612,7 @@ class NewEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPagi model = NewEmailProvider context_object_name = 'providers' - template_name = 'member/new_email_providers.html' + template_name = 'member/settings/new_email_providers.html' queryset = NewEmailProvider.objects \ .select_related('user') \ .select_related('user__profile') \ @@ -641,7 +641,7 @@ class BannedEmailProvidersList(LoginRequiredMixin, PermissionRequiredMixin, ZdSP model = BannedEmailProvider context_object_name = 'providers' - template_name = 'member/banned_email_providers.html' + template_name = 'member/settings/banned_email_providers.html' queryset = BannedEmailProvider.objects \ .select_related('moderator') \ .select_related('moderator__profile') \ @@ -654,7 +654,7 @@ class MembersWithProviderList(LoginRequiredMixin, PermissionRequiredMixin, ZdSPa model = User context_object_name = 'members' - template_name = 'member/members_with_provider.html' + template_name = 'member/settings/members_with_provider.html' def get_object(self): return get_object_or_404(BannedEmailProvider, pk=self.kwargs['provider_pk']) @@ -669,14 +669,14 @@ def get_queryset(self): return Profile.objects \ .select_related('user') \ .order_by('-last_visit') \ - .filter(user__email__endswith='@{}'.format(provider.provider)) + .filter(user__email__contains='@{}'.format(provider.provider)) class AddBannedEmailProvider(LoginRequiredMixin, PermissionRequiredMixin, CreateView): permissions = ['member.change_bannedemailprovider'] model = BannedEmailProvider - template_name = 'member/add_banned_email_provider.html' + template_name = 'member/settings/add_banned_email_provider.html' form_class = BannedEmailProviderForm success_url = reverse_lazy('banned-email-providers') @@ -695,7 +695,7 @@ def remove_banned_email_provider(request, provider_pk): provider = get_object_or_404(BannedEmailProvider, pk=provider_pk) provider.delete() - messages.success(request, _(u'Le fournisseur a été débanni.')) + messages.success(request, _(u'Le fournisseur « {} » a été débanni.').format(provider.provider)) return redirect('banned-email-providers') @@ -895,7 +895,7 @@ def activate_account(request): False) token.delete() - # create an alert for staff if it's a new provider + # create an alert for the staff if it's a new provider if usr.email: provider = re.findall(r'@(.+)', usr.email)[0] if not NewEmailProvider.objects.filter(provider=provider).exists() \ diff --git a/zds/settings.py b/zds/settings.py index 81c0141ed4..ff99896467 100644 --- a/zds/settings.py +++ b/zds/settings.py @@ -462,7 +462,7 @@ 'bot_group': u'bot', 'dev_group': u'devs', 'members_per_page': 100, - 'providers_per_page': 21, + 'providers_per_page': 50, 'update_last_visit_interval': 600, # seconds }, 'gallery': { From f1da501ac674e89a9d6192ed9fbfcfdaa50f7c31 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Thu, 11 May 2017 18:46:40 +0200 Subject: [PATCH 40/75] PEP-8 --- zds/member/validators.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/zds/member/validators.py b/zds/member/validators.py index f200027425..bacb6c9c92 100644 --- a/zds/member/validators.py +++ b/zds/member/validators.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -import re - from django.contrib.auth.models import User from django.core.exceptions import ValidationError from django.core.validators import EmailValidator From 5fa7f70119d5015743b31346f4dd2f71fd37948b Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 13 May 2017 12:22:34 +0200 Subject: [PATCH 41/75] =?UTF-8?q?Fix=20d'=C3=A9ventuels=20probl=C3=A8mes?= =?UTF-8?q?=20de=20casse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zds/member/forms.py | 4 ++++ zds/member/validators.py | 2 +- zds/member/views.py | 10 +++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/zds/member/forms.py b/zds/member/forms.py index fbc16ac08d..188352e99b 100644 --- a/zds/member/forms.py +++ b/zds/member/forms.py @@ -614,3 +614,7 @@ def __init__(self, *args, **kwargs): ButtonHolder( StrictButton(_(u'Bannir ce fournisseur'), type='submit'), )) + + def clean_provider(self): + data = self.cleaned_data['provider'] + return data.lower() diff --git a/zds/member/validators.py b/zds/member/validators.py index bacb6c9c92..cb618a7d53 100644 --- a/zds/member/validators.py +++ b/zds/member/validators.py @@ -46,7 +46,7 @@ def __call__(self, value, check_username_available=True): # check if provider is blacklisted blacklist = BannedEmailProvider.objects.values_list('provider', flat=True) for provider in blacklist: - if '@{}'.format(provider) in value: + if '@{}'.format(provider) in value.lower(): raise ValidationError(_(u'Ce fournisseur ne peut pas être utilisé.'), code=self.code) # check if email is used by another user diff --git a/zds/member/views.py b/zds/member/views.py index 52e8278c35..d8ec2ee8e9 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -322,9 +322,9 @@ def update_profile(self, profile, form): if new_email and new_email != previous_email: profile.user.email = new_email # create an alert for the staff if it's a new provider - provider = re.findall(r'@(.+)', new_email)[0] + provider = re.findall(r'@(.+)', new_email)[0].lower() if not NewEmailProvider.objects.filter(provider=provider).exists() \ - and not User.objects.filter(email__endswith='@{}'.format(provider)) \ + and not User.objects.filter(email__iendswith='@{}'.format(provider)) \ .exclude(pk=profile.user.pk).exists(): NewEmailProvider.objects.create(user=profile.user, provider=provider, use='EMAIL_EDIT') @@ -669,7 +669,7 @@ def get_queryset(self): return Profile.objects \ .select_related('user') \ .order_by('-last_visit') \ - .filter(user__email__contains='@{}'.format(provider.provider)) + .filter(user__email__icontains='@{}'.format(provider.provider)) class AddBannedEmailProvider(LoginRequiredMixin, PermissionRequiredMixin, CreateView): @@ -897,9 +897,9 @@ def activate_account(request): # create an alert for the staff if it's a new provider if usr.email: - provider = re.findall(r'@(.+)', usr.email)[0] + provider = re.findall(r'@(.+)', usr.email)[0].lower() if not NewEmailProvider.objects.filter(provider=provider).exists() \ - and not User.objects.filter(email__endswith='@{}'.format(provider)) \ + and not User.objects.filter(email__iendswith='@{}'.format(provider)) \ .exclude(pk=usr.pk).exists(): NewEmailProvider.objects.create(user=usr, provider=provider, use='NEW_ACCOUNT') From 1776dcd4a7335fb7e25b8e324ccd4b3c6dde75fe Mon Sep 17 00:00:00 2001 From: GCodeur Date: Tue, 16 May 2017 18:05:56 +0200 Subject: [PATCH 42/75] unicolde_literals --- zds/member/validators.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/zds/member/validators.py b/zds/member/validators.py index cb618a7d53..920a5befe2 100644 --- a/zds/member/validators.py +++ b/zds/member/validators.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +from __future__ import unicolde_literals + from django.contrib.auth.models import User from django.core.exceptions import ValidationError from django.core.validators import EmailValidator @@ -18,7 +20,7 @@ def validate_not_empty(value): :return: """ if value is None or not value.strip(): - raise ValidationError(_(u'Le champs ne peut être vide')) + raise ValidationError(_('Le champs ne peut être vide')) class ZdSEmailValidator(EmailValidator): @@ -30,7 +32,7 @@ class ZdSEmailValidator(EmailValidator): - remove whitelist check - add custom errors and translate them into French """ - message = _(u'Utilisez une adresse de courriel valide.') + message = _('Utilisez une adresse de courriel valide.') def __call__(self, value, check_username_available=True): value = force_text(value) @@ -47,15 +49,15 @@ def __call__(self, value, check_username_available=True): blacklist = BannedEmailProvider.objects.values_list('provider', flat=True) for provider in blacklist: if '@{}'.format(provider) in value.lower(): - raise ValidationError(_(u'Ce fournisseur ne peut pas être utilisé.'), code=self.code) + raise ValidationError(_('Ce fournisseur ne peut pas être utilisé.'), code=self.code) # check if email is used by another user user_count = User.objects.filter(email=value).count() if check_username_available and user_count > 0: - raise ValidationError(_(u'Cette adresse courriel est déjà utilisée'), code=self.code) + raise ValidationError(_('Cette adresse courriel est déjà utilisée'), code=self.code) # check if email exists in database elif not check_username_available and user_count == 0: - raise ValidationError(_(u'Cette adresse courriel n\'existe pas'), code=self.code) + raise ValidationError(_('Cette adresse courriel n\'existe pas'), code=self.code) if domain_part and not self.validate_domain_part(domain_part): # Try for possible IDN domain-part @@ -81,15 +83,15 @@ def validate_zds_username(value, check_username_available=True): msg = None user_count = User.objects.filter(username=value).count() if ',' in value: - msg = _(u'Le nom d\'utilisateur ne peut contenir de virgules') + msg = _('Le nom d\'utilisateur ne peut contenir de virgules') elif value != value.strip(): - msg = _(u'Le nom d\'utilisateur ne peut commencer ou finir par des espaces') + msg = _('Le nom d\'utilisateur ne peut commencer ou finir par des espaces') elif contains_utf8mb4(value): - msg = _(u'Le nom d\'utilisateur ne peut pas contenir des caractères utf8mb4') + msg = _('Le nom d\'utilisateur ne peut pas contenir des caractères utf8mb4') elif check_username_available and user_count > 0: - msg = _(u'Ce nom d\'utilisateur est déjà utilisé') + msg = _('Ce nom d\'utilisateur est déjà utilisé') elif not check_username_available and user_count == 0: - msg = _(u'Ce nom d\'utilisateur n\'existe pas') + msg = _('Ce nom d\'utilisateur n\'existe pas') if msg is not None: raise ValidationError(msg) @@ -101,7 +103,7 @@ def validate_zds_password(value): :return: """ if contains_utf8mb4(value): - raise ValidationError(_(u'Le mot de passe ne peut pas contenir des caractères utf8mb4')) + raise ValidationError(_('Le mot de passe ne peut pas contenir des caractères utf8mb4')) def validate_passwords(cleaned_data, password_label='password', password_confirm_label='password_confirm', @@ -122,7 +124,7 @@ def validate_passwords(cleaned_data, password_label='password', password_confirm username = cleaned_data.get('username') if not password_confirm == password: - msg = _(u'Les mots de passe sont différents') + msg = _('Les mots de passe sont différents') if password_label in cleaned_data: del cleaned_data[password_label] @@ -133,7 +135,7 @@ def validate_passwords(cleaned_data, password_label='password', password_confirm if username is not None: # Check that password != username if password == username: - msg = _(u'Le mot de passe doit être différent du pseudo') + msg = _('Le mot de passe doit être différent du pseudo') if password_label in cleaned_data: del cleaned_data[password_label] if password_confirm_label in cleaned_data: From 7324603c89b6eb9b33306519ca41e7299059c7a6 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Tue, 16 May 2017 18:35:07 +0200 Subject: [PATCH 43/75] Mauvais copier-coller --- zds/member/validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zds/member/validators.py b/zds/member/validators.py index 920a5befe2..2b0b70a572 100644 --- a/zds/member/validators.py +++ b/zds/member/validators.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from __future__ import unicolde_literals +from __future__ import unicode_literals from django.contrib.auth.models import User from django.core.exceptions import ValidationError From 37df01fc22750133169d2828ef87a86fda49afc6 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Fri, 19 May 2017 23:05:18 +0200 Subject: [PATCH 44/75] Review d'@artragis --- zds/member/__init__.py | 3 +++ zds/member/views.py | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/zds/member/__init__.py b/zds/member/__init__.py index da1dbf64a1..b9366863d7 100644 --- a/zds/member/__init__.py +++ b/zds/member/__init__.py @@ -5,3 +5,6 @@ NEW_PROVIDER_USES = [('NEW_ACCOUNT', _('Nouveau compte')), ('EMAIL_EDIT', _("Édition de l'adresse e-mail"))] + +NEW_ACCOUNT = 'NEW_ACCOUNT' +EMAIL_EDIT = 'EMAIL_EDIT' diff --git a/zds/member/views.py b/zds/member/views.py index d8ec2ee8e9..e7f48897bc 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -30,6 +30,7 @@ from zds.forum.models import Topic, TopicRead from zds.gallery.forms import ImageAsAvatarForm from zds.gallery.models import UserGallery +from zds.member import NEW_ACCOUNT, EMAIL_EDIT from zds.member.commons import ProfileCreate, TemporaryReadingOnlySanction, ReadingOnlySanction, \ DeleteReadingOnlySanction, TemporaryBanSanction, BanSanction, DeleteBanSanction, TokenGenerator from zds.member.decorator import can_write_and_read_now, LoginRequiredMixin, PermissionRequiredMixin @@ -322,11 +323,11 @@ def update_profile(self, profile, form): if new_email and new_email != previous_email: profile.user.email = new_email # create an alert for the staff if it's a new provider - provider = re.findall(r'@(.+)', new_email)[0].lower() + provider = provider = new_email.split('@')[-1].lower() if not NewEmailProvider.objects.filter(provider=provider).exists() \ and not User.objects.filter(email__iendswith='@{}'.format(provider)) \ .exclude(pk=profile.user.pk).exists(): - NewEmailProvider.objects.create(user=profile.user, provider=provider, use='EMAIL_EDIT') + NewEmailProvider.objects.create(user=profile.user, provider=provider, use=EMAIL_EDIT) def get_success_url(self): profile = self.get_object() @@ -897,11 +898,11 @@ def activate_account(request): # create an alert for the staff if it's a new provider if usr.email: - provider = re.findall(r'@(.+)', usr.email)[0].lower() + provider = usr.email.split('@')[-1].lower() if not NewEmailProvider.objects.filter(provider=provider).exists() \ and not User.objects.filter(email__iendswith='@{}'.format(provider)) \ .exclude(pk=usr.pk).exists(): - NewEmailProvider.objects.create(user=usr, provider=provider, use='NEW_ACCOUNT') + NewEmailProvider.objects.create(user=usr, provider=provider, use=NEW_ACCOUNT) form = LoginForm(initial={'username': usr.username}) return render(request, 'member/register/token_success.html', {'usr': usr, 'form': form}) From 0a79484cbde426175afc534b2daf85e1c4ca447c Mon Sep 17 00:00:00 2001 From: GCodeur Date: Mon, 22 May 2017 08:38:17 +0200 Subject: [PATCH 45/75] PEP-8 --- zds/member/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/zds/member/views.py b/zds/member/views.py index e7f48897bc..2ec37b5cb5 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -2,7 +2,6 @@ import uuid from datetime import datetime, timedelta -import re from oauth2_provider.models import AccessToken From 3b26a68494ceec139dc983c0ee5907ef5d411843 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Fri, 26 May 2017 17:37:33 +0200 Subject: [PATCH 46/75] Review de @gustavi --- templates/base.html | 2 +- .../member/settings/add_banned_email_provider.html | 4 +++- .../member/settings/banned_email_providers.html | 4 +++- .../member/settings/members_with_provider.html | 4 +++- templates/member/settings/new_email_providers.html | 4 +++- .../0011_bannedemailprovider_newemailprovider.py | 7 ++++++- zds/member/models.py | 14 +++++++------- zds/member/urls.py | 12 ++++++------ zds/settings.py | 2 +- 9 files changed, 33 insertions(+), 20 deletions(-) diff --git a/templates/base.html b/templates/base.html index 7319a3e920..b4d92cbe61 100644 --- a/templates/base.html +++ b/templates/base.html @@ -599,7 +599,7 @@ {% with new_providers_count=user|new_providers_count %}
  • - {% trans "Nouveaux fournisseurs" %} + {% trans "Fournisseurs e-mail" %} {% if new_providers_count > 0 %} ({{ new_providers_count }}) {% endif %} diff --git a/templates/member/settings/add_banned_email_provider.html b/templates/member/settings/add_banned_email_provider.html index 907c34ce7c..cc673a6f6e 100644 --- a/templates/member/settings/add_banned_email_provider.html +++ b/templates/member/settings/add_banned_email_provider.html @@ -44,7 +44,9 @@ {% block sidebar_actions %} {% endblock %} \ No newline at end of file diff --git a/templates/member/settings/banned_email_providers.html b/templates/member/settings/banned_email_providers.html index 99e7f993ef..86c93e812b 100644 --- a/templates/member/settings/banned_email_providers.html +++ b/templates/member/settings/banned_email_providers.html @@ -65,7 +65,9 @@ {% block sidebar_actions %}
    - {% trans "Bannir" %} {% trans "un fournisseur" %} + {% blocktrans %} + Bannir un fournisseur + {% endblocktrans %} diff --git a/templates/member/settings/members_with_provider.html b/templates/member/settings/members_with_provider.html index eab77d0c76..75879544df 100644 --- a/templates/member/settings/members_with_provider.html +++ b/templates/member/settings/members_with_provider.html @@ -51,7 +51,9 @@ {% block sidebar_actions %} {% endblock %} \ No newline at end of file diff --git a/templates/member/settings/new_email_providers.html b/templates/member/settings/new_email_providers.html index 0340fa72ae..cbfc37e609 100644 --- a/templates/member/settings/new_email_providers.html +++ b/templates/member/settings/new_email_providers.html @@ -78,7 +78,9 @@ - {% trans "Bannir" %} {% trans "un fournisseur" %} + {% blocktrans %} + Bannir un fournisseur + {% endblocktrans %}
    {% endblock %} \ No newline at end of file diff --git a/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py b/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py index 698e31c919..82dd90a772 100644 --- a/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py +++ b/zds/member/migrations/0011_bannedemailprovider_newemailprovider.py @@ -854,7 +854,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('provider', models.CharField(unique=True, max_length=253, verbose_name='Fournisseur', db_index=True)), - ('use', models.CharField(max_length=11, choices=[('NEW_ACCOUNT', 'Nouveau compte'), ('EMAIL_EDIT', "\xc9dition de l'adresse e-mail")])), + ('use', models.CharField(max_length=11, verbose_name='Utilisation', choices=[('NEW_ACCOUNT', 'Nouveau compte'), ('EMAIL_EDIT', "\xc9dition de l'adresse e-mail")])), ('date', models.DateTimeField(db_column='alert_date', auto_now_add=True, verbose_name="Date de l'alerte", db_index=True)), ('user', models.ForeignKey(related_name='new_providers', verbose_name='Utilisateur concern\xe9', to=settings.AUTH_USER_MODEL)), ], @@ -864,4 +864,9 @@ class Migration(migrations.Migration): }, ), migrations.RunPython(forwards_func), + migrations.AlterField( + model_name='profile', + name='show_markdown_help', + field=models.BooleanField(default=True, verbose_name="Afficher l'aide Markdown dans l'\xe9diteur"), + ), ] diff --git a/zds/member/models.py b/zds/member/models.py index 78594b8897..6bc7d3d6ce 100644 --- a/zds/member/models.py +++ b/zds/member/models.py @@ -503,11 +503,11 @@ class Meta: verbose_name_plural = 'Nouveaux fournisseurs' provider = models.CharField('Fournisseur', max_length=253, unique=True, db_index=True) - use = models.CharField(max_length=11, choices=NEW_PROVIDER_USES) - user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='Utilisateur concerné', + use = models.CharField('Utilisation', max_length=11, choices=NEW_PROVIDER_USES) + user = models.ForeignKey(User, verbose_name='Utilisateur concerné', on_delete=models.CASCADE, related_name='new_providers', db_index=True) - date = models.DateTimeField(auto_now_add=True, db_index=True, - verbose_name="Date de l'alerte", db_column='alert_date') + date = models.DateTimeField("Date de l'alerte", auto_now_add=True, db_index=True, + db_column='alert_date') def __str__(self): return 'Alert about the new provider {}'.format(self.provider) @@ -525,10 +525,10 @@ class Meta: verbose_name_plural = 'Fournisseurs bannis' provider = models.CharField('Fournisseur', max_length=253, unique=True, db_index=True) - moderator = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='Modérateur', + moderator = models.ForeignKey(User, verbose_name='Modérateur', on_delete=models.CASCADE, related_name='banned_providers', db_index=True) - date = models.DateTimeField(auto_now_add=True, db_index=True, - verbose_name='Date du bannissement', db_column='ban_date') + date = models.DateTimeField('Date du bannissement', auto_now_add=True, db_index=True, + db_column='ban_date') def __str__(self): return 'Ban of the {} provider'.format(self.provider) diff --git a/zds/member/urls.py b/zds/member/urls.py index 11b4c3776d..887a0c7850 100644 --- a/zds/member/urls.py +++ b/zds/member/urls.py @@ -31,14 +31,14 @@ url(r'^profil/multi/(?P.+)/$', member_from_ip, name='member-from-ip'), # email providers - url(r'^fournisseurs/nouveaux/$', NewEmailProvidersList.as_view(), name='new-email-providers'), - url(r'^fournisseurs/nouveaux/verifier/(?P\d+)/$', check_new_email_provider, + url(r'^fournisseurs-email/nouveaux/$', NewEmailProvidersList.as_view(), name='new-email-providers'), + url(r'^fournisseurs-email/nouveaux/verifier/(?P\d+)/$', check_new_email_provider, name='check-new-email-provider'), - url(r'^fournisseurs/bannis/$', BannedEmailProvidersList.as_view(), name='banned-email-providers'), - url(r'^fournisseurs/bannis/ajouter/$', AddBannedEmailProvider.as_view(), name='add-banned-email-provider'), - url(r'^fournisseurs/bannis/rechercher/(?P\d+)/$', MembersWithProviderList.as_view(), + url(r'^fournisseurs-email/bannis/$', BannedEmailProvidersList.as_view(), name='banned-email-providers'), + url(r'^fournisseurs-email/bannis/ajouter/$', AddBannedEmailProvider.as_view(), name='add-banned-email-provider'), + url(r'^fournisseurs-email/bannis/rechercher/(?P\d+)/$', MembersWithProviderList.as_view(), name='members-with-provider'), - url(r'^fournisseurs/bannis/supprimer/(?P\d+)/$', remove_banned_email_provider, + url(r'^fournisseurs-email/bannis/supprimer/(?P\d+)/$', remove_banned_email_provider, name='remove-banned-email-provider'), # user rights diff --git a/zds/settings.py b/zds/settings.py index ff99896467..4420a3b25d 100644 --- a/zds/settings.py +++ b/zds/settings.py @@ -462,7 +462,7 @@ 'bot_group': u'bot', 'dev_group': u'devs', 'members_per_page': 100, - 'providers_per_page': 50, + 'providers_per_page': 100, 'update_last_visit_interval': 600, # seconds }, 'gallery': { From e551d00db75024f22eb2f248089d5a42c9172305 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 27 May 2017 19:13:57 +0200 Subject: [PATCH 47/75] Placeholder pour le fournisseur --- zds/member/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zds/member/forms.py b/zds/member/forms.py index 188352e99b..12348f1eb2 100644 --- a/zds/member/forms.py +++ b/zds/member/forms.py @@ -599,7 +599,7 @@ class Meta: widgets = { 'provider': forms.TextInput(attrs={ 'autofocus': 'on', - 'placeholder': _(u"La partie qui suit l'arobase dans l'adresse e-mail."), + 'placeholder': _(u"Le nom de domaine à bannir."), }), } From 942afe2a99259fd2d6b6115cf1959559ed55ba78 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 27 May 2017 19:41:40 +0200 Subject: [PATCH 48/75] PEP-8 --- zds/member/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zds/member/forms.py b/zds/member/forms.py index 12348f1eb2..29f6fbf15d 100644 --- a/zds/member/forms.py +++ b/zds/member/forms.py @@ -599,7 +599,7 @@ class Meta: widgets = { 'provider': forms.TextInput(attrs={ 'autofocus': 'on', - 'placeholder': _(u"Le nom de domaine à bannir."), + 'placeholder': _(u'Le nom de domaine à bannir.'), }), } From 12f6c1391845a00a589f82b406b8fb5919e84015 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 3 Jun 2017 17:49:00 +0200 Subject: [PATCH 49/75] Corrige une faute d'anglais (#4342) --- zds/tutorialv2/mixins.py | 2 +- zds/tutorialv2/models/models_database.py | 4 ++-- zds/tutorialv2/tests/tests_opinion_views.py | 2 +- zds/tutorialv2/views/views_validations.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zds/tutorialv2/mixins.py b/zds/tutorialv2/mixins.py index 9fa34571d7..313f69aa3c 100644 --- a/zds/tutorialv2/mixins.py +++ b/zds/tutorialv2/mixins.py @@ -262,7 +262,7 @@ def get_context_data(self, **kwargs): context['can_edit'] = self.is_author context['is_staff'] = self.is_staff if self.object.type == 'OPINION': - context['can_publish'] = not self.object.is_definitely_unpublished() + context['can_publish'] = not self.object.is_permanently_unpublished() if self.sha != self.object.sha_draft: context['version'] = self.sha diff --git a/zds/tutorialv2/models/models_database.py b/zds/tutorialv2/models/models_database.py index a3646c1294..a30949977f 100644 --- a/zds/tutorialv2/models/models_database.py +++ b/zds/tutorialv2/models/models_database.py @@ -289,8 +289,8 @@ def is_public(self, sha): """ return self.in_public() and sha == self.sha_public - def is_definitely_unpublished(self): - """Is this content definitely unpublished by a moderator ?""" + def is_permanently_unpublished(self): + """Is this content permanently unpublished by a moderator ?""" return PickListOperation.objects.filter(content=self, operation='REMOVE_PUB', is_effective=True).exists() diff --git a/zds/tutorialv2/tests/tests_opinion_views.py b/zds/tutorialv2/tests/tests_opinion_views.py index 92bd7df2ba..8beb856d5a 100644 --- a/zds/tutorialv2/tests/tests_opinion_views.py +++ b/zds/tutorialv2/tests/tests_opinion_views.py @@ -547,7 +547,7 @@ def test_ignore_opinion(self): result = self.client.get(reverse('validation:list-opinion')) self.assertNotContains(result, opinion.title) - def test_definitely_unpublish_opinion(self): + def test_permanently_unpublish_opinion(self): opinion = PublishableContentFactory(type='OPINION') opinion.authors.add(self.user_author) diff --git a/zds/tutorialv2/views/views_validations.py b/zds/tutorialv2/views/views_validations.py index da7505bded..0501f390d1 100644 --- a/zds/tutorialv2/views/views_validations.py +++ b/zds/tutorialv2/views/views_validations.py @@ -570,7 +570,7 @@ def get_form_kwargs(self): def form_valid(self, form): # get database representation db_object = self.object - if self.object.is_definitely_unpublished(): + if self.object.is_permanently_unpublished(): raise PermissionDenied versioned = self.versioned_object self.success_url = versioned.get_absolute_url() From 5557494a241fc4cca1eee21cf6a841f3e6c48df2 Mon Sep 17 00:00:00 2001 From: Augustin Laville Date: Sat, 3 Jun 2017 18:42:43 +0200 Subject: [PATCH 50/75] Fix #4363 : corrige une typo dans la documentation d'ES --- doc/source/install/install-es.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/install/install-es.rst b/doc/source/install/install-es.rst index ae1c44e7fd..39eb08aa99 100644 --- a/doc/source/install/install-es.rst +++ b/doc/source/install/install-es.rst @@ -152,7 +152,7 @@ Pour réindexer les nouvelles données, utilisez la commande suivante : .. sourcecode:: bash - python manage.py es_manager index-flagged + python manage.py es_manager index_flagged Plus d'informations sur la commande ``es_manager`` sont disponibles sur la page `concernant la recherche sur ZdS <../back-end/searchv2.html#indexer-les-donnees-de-zds>`_. From 26d44f4b76ff988cea7e80b9fbb6631ea2dae758 Mon Sep 17 00:00:00 2001 From: Augustin Laville Date: Sat, 3 Jun 2017 19:07:31 +0200 Subject: [PATCH 51/75] =?UTF-8?q?Fix=20#4353:=20curseur=20pointeur=20sur?= =?UTF-8?q?=20bouton=20d=C3=A9connexion=20+=20menu=20mobile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/scss/components/_mobile-menu.scss | 1 + assets/scss/layout/_header.scss | 3 +++ 2 files changed, 4 insertions(+) diff --git a/assets/scss/components/_mobile-menu.scss b/assets/scss/components/_mobile-menu.scss index c69152e54f..2ea3716aae 100644 --- a/assets/scss/components/_mobile-menu.scss +++ b/assets/scss/components/_mobile-menu.scss @@ -229,6 +229,7 @@ float: left; height: 50px; width: 50px; + cursor: pointer; &:after { display: block; diff --git a/assets/scss/layout/_header.scss b/assets/scss/layout/_header.scss index be5fa99c98..61566361c4 100644 --- a/assets/scss/layout/_header.scss +++ b/assets/scss/layout/_header.scss @@ -467,6 +467,9 @@ .logbox .dropdown.my-account-dropdown ul li { height: 30px; line-height: 30px; + button { + cursor: pointer; + } } .lt-ie9 .dropdown { From e25ed49c54c6e995119324a5f9654f9eb5647ebb Mon Sep 17 00:00:00 2001 From: Theodicy Date: Sat, 3 Jun 2017 23:35:45 +0200 Subject: [PATCH 52/75] =?UTF-8?q?Mise=20=C3=A0=20jour=20du=20CDN=20de=20Ma?= =?UTF-8?q?thJax=20(#4345)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Mise à jour du CDN de MathJax * Ajouts du crossorigin et checksum --- templates/base.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/base.html b/templates/base.html index b4d92cbe61..7ebc5c6114 100644 --- a/templates/base.html +++ b/templates/base.html @@ -783,6 +783,9 @@

    {{ headlin messageStyle: "none", }); - + From ee5cae6652ac3534b06812701bb275dc5d0141cf Mon Sep 17 00:00:00 2001 From: Laville Augustin Date: Sun, 4 Jun 2017 09:49:33 +0200 Subject: [PATCH 53/75] Fix #4362 : ajoute un message en cas d'absence de notification (#4365) --- templates/notification/followed.html | 48 +++++++++++++++------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/templates/notification/followed.html b/templates/notification/followed.html index 252411c263..1cb7dd3cc4 100644 --- a/templates/notification/followed.html +++ b/templates/notification/followed.html @@ -24,29 +24,33 @@ {% block content %} {% include "misc/paginator.html" with position="top" %} - From 1c22d82235d28a6f543eebdc421c72f9b8c3a153 Mon Sep 17 00:00:00 2001 From: Laville Augustin Date: Sun, 11 Jun 2017 18:42:38 +0200 Subject: [PATCH 60/75] Update Django version (#4347) --- manage.py | 46 +--------- requirements.txt | 4 +- templates/base.html | 2 +- templates/gallery/base.html | 4 +- templates/gallery/gallery/details.html | 2 +- templates/gallery/gallery/list.html | 2 +- templates/rest_framework_swagger/index.html | 70 +++++---------- zds/api/urls.py | 9 +- zds/forum/views.py | 1 + zds/gallery/tests/tests_views.py | 6 +- zds/gallery/views.py | 4 +- zds/member/api/views.py | 2 + zds/member/forms.py | 1 - zds/member/managers.py | 2 +- zds/member/tests/tests_forms.py | 6 +- zds/mp/api/views.py | 2 + zds/settings.py | 18 ++-- zds/settings_test_travis.py | 5 +- .../management/commands/generate_pdf.py | 16 ++-- .../commands/upgrade_manifest_to_v2.py | 8 +- zds/tutorialv2/tests/tests_utils.py | 4 +- zds/tutorialv2/tests/tests_views.py | 2 +- zds/urls.py | 6 ++ .../management/commands/load_factory_data.py | 7 +- .../management/commands/load_fixtures.py | 86 +++++++------------ 25 files changed, 122 insertions(+), 193 deletions(-) diff --git a/manage.py b/manage.py index 758d307eec..935c1f31c5 100644 --- a/manage.py +++ b/manage.py @@ -1,54 +1,12 @@ import os import sys - -def patch_mysql_sql_create_model(original): - """ - Inspired by github.com/miyagi389/zipcode-django-python - The MIT License - Copyright (c) 2014 miyagi389 - - :param :class:`django.db.backends.creation.BaseDatabaseCreation` original: BaseDatabaseCreation - :return: BaseDatabaseCreation - :rtype: :class:`django.db.backends.creation.BaseDatabaseCreation` - """ - - def revised(self, model, style, known_models=set()): - """ - :class:`django.db.backends.creation.BaseDatabaseCreation` - """ - - fullname = self.__module__ + '.' + self.__class__.__name__ - if fullname == 'django.db.backends.mysql.creation.DatabaseCreation': - # the migration will run MySQL - sql_statements, pending_references = original(self, model, style, known_models) - - final_output = [] - for statement in sql_statements: - if not statement.startswith('CREATE TABLE'): - continue - - end = '' - if statement.endswith(';'): - end = ';' - statement = statement[:-1] - - statement += 'ROW_FORMAT=DYNAMIC{}'.format(end) - - final_output.append(statement) - - return final_output, pending_references - else: - return original(self, model, style, known_models) - - return revised - - if __name__ == '__main__': os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'zds.settings') - if len(sys.argv) > 1 and sys.argv[1] in ['migrate', 'test']: - from django.db.backends.base.creation import BaseDatabaseCreation - BaseDatabaseCreation.sql_create_model = patch_mysql_sql_create_model(BaseDatabaseCreation.sql_create_model) + from zds.settings import DATABASES + if DATABASES['default']['ENGINE'] == 'django.db.backends.mysql': from django.db.backends.mysql.schema import DatabaseSchemaEditor DatabaseSchemaEditor.sql_create_table += ' ROW_FORMAT=DYNAMIC' diff --git a/requirements.txt b/requirements.txt index 0c2241642d..9dfb45fac0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ elasticsearch==5.3.0 elasticsearch-dsl==5.2.0 # Explicit dependencies (references in code) -Django==1.8.18 +Django==1.10.7 django-crispy-forms==1.6.1 django-model-utils==2.6.1 django-munin==0.2.2 @@ -27,7 +27,7 @@ djangorestframework-xml==1.3.0 django-filter==1.0.2 django-oauth-toolkit==0.12.0 drf-extensions==0.3.1 -django-rest-swagger==0.3.6 +django-rest-swagger==2.0.7 django-cors-middleware==1.3.1 dry-rest-permissions==0.1.9 diff --git a/templates/base.html b/templates/base.html index 7ebc5c6114..502d341368 100644 --- a/templates/base.html +++ b/templates/base.html @@ -725,7 +725,7 @@

    {{ headlin

  • {% trans "Fournisseur" %}{% trans "Utilisation" %} {% trans "Compte concerné" %} {% trans "Date d'utilisation" %} {% trans "Actions" %}
    {{ provider.provider }}{{ provider.get_use_display }} {% include 'misc/member_item.part.html' with member=provider.user avatar=True %} {{ provider.date|format_date|capfirst }} diff --git a/zds/member/__init__.py b/zds/member/__init__.py index e69de29bb2..da1dbf64a1 100644 --- a/zds/member/__init__.py +++ b/zds/member/__init__.py @@ -0,0 +1,7 @@ +# coding: utf-8 + +from __future__ import unicode_literals +from django.utils.translation import ugettext_lazy as _ + + +NEW_PROVIDER_USES = [('NEW_ACCOUNT', _('Nouveau compte')), ('EMAIL_EDIT', _("Édition de l'adresse e-mail"))] diff --git a/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py b/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py index 59016a8966..bac24c4484 100644 --- a/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py +++ b/zds/member/migrations/0010_bannedemailprovider_newemailprovider.py @@ -31,6 +31,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('provider', models.CharField(unique=True, max_length=253, verbose_name='Fournisseur', db_index=True)), + ('use', models.CharField(max_length=11, choices=[('NEW_ACCOUNT', 'Nouveau compte'), ('EMAIL_EDIT', "\xc9dition de l'adresse e-mail")])), ('date', models.DateTimeField(db_column='alert_date', auto_now_add=True, verbose_name="Date de l'alerte", db_index=True)), ('user', models.ForeignKey(related_name='new_providers', verbose_name='Utilisateur concern\xe9', to=settings.AUTH_USER_MODEL)), ], diff --git a/zds/member/models.py b/zds/member/models.py index b97809fa6e..78594b8897 100644 --- a/zds/member/models.py +++ b/zds/member/models.py @@ -18,6 +18,7 @@ from django.utils.translation import ugettext_lazy as _ from zds.forum.models import Post, Topic +from zds.member import NEW_PROVIDER_USES from zds.member.managers import ProfileManager from zds.tutorialv2.models.models_database import PublishableContent, PublishedContent from zds.utils.models import Alert @@ -502,6 +503,7 @@ class Meta: verbose_name_plural = 'Nouveaux fournisseurs' provider = models.CharField('Fournisseur', max_length=253, unique=True, db_index=True) + use = models.CharField(max_length=11, choices=NEW_PROVIDER_USES) user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='Utilisateur concerné', related_name='new_providers', db_index=True) date = models.DateTimeField(auto_now_add=True, db_index=True, diff --git a/zds/member/views.py b/zds/member/views.py index 53e0d02a3b..c7f56f7f22 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -325,7 +325,7 @@ def update_profile(self, profile, form): provider = re.findall(r'@(.+)', new_email)[0] if not NewEmailProvider.objects.filter(provider=provider).exists() \ and not User.objects.filter(email__endswith='@{}'.format(provider)): - NewEmailProvider.objects.create(user=profile.user, provider=provider) + NewEmailProvider.objects.create(user=profile.user, provider=provider, use='EMAIL_EDIT') def get_success_url(self): profile = self.get_object() @@ -865,7 +865,7 @@ def activate_account(request): provider = re.findall(r'@(.+)', usr.email)[0] if not NewEmailProvider.objects.filter(provider=provider).exists() \ and not User.objects.filter(email__endswith='@{}'.format(provider)): - NewEmailProvider.objects.create(user=usr, provider=provider) + NewEmailProvider.objects.create(user=usr, provider=provider, use='NEW_ACCOUNT') send_mp(bot, [usr], From 69c3f5a77a3ec4d14b59dfee3bc5398b9b66cc09 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 6 May 2017 12:28:09 +0200 Subject: [PATCH 29/75] Fixe le menu --- assets/scss/components/_header-dropdown.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scss/components/_header-dropdown.scss b/assets/scss/components/_header-dropdown.scss index 34af611ede..710bbefd06 100644 --- a/assets/scss/components/_header-dropdown.scss +++ b/assets/scss/components/_header-dropdown.scss @@ -107,7 +107,7 @@ padding: 0; .dropdown-list { - max-height: 330px; + max-height: 390px; overflow-x: hidden; overflow-y: auto; From c82827903963766fed141bd35009d47da3a74868 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 6 May 2017 13:48:27 +0200 Subject: [PATCH 30/75] Corrige l'alerte sur l'inscription --- zds/member/views.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/zds/member/views.py b/zds/member/views.py index c7f56f7f22..5d3431c11e 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -324,7 +324,8 @@ def update_profile(self, profile, form): # create an alert for staff if it's a new provider provider = re.findall(r'@(.+)', new_email)[0] if not NewEmailProvider.objects.filter(provider=provider).exists() \ - and not User.objects.filter(email__endswith='@{}'.format(provider)): + and not User.objects.filter(email__endswith='@{}'.format(provider)) \ + .exclude(pk=profile.user.pk).exists(): NewEmailProvider.objects.create(user=profile.user, provider=provider, use='EMAIL_EDIT') def get_success_url(self): @@ -860,13 +861,6 @@ def activate_account(request): } ) - # create an alert for staff if it's a new provider - if usr.email: - provider = re.findall(r'@(.+)', usr.email)[0] - if not NewEmailProvider.objects.filter(provider=provider).exists() \ - and not User.objects.filter(email__endswith='@{}'.format(provider)): - NewEmailProvider.objects.create(user=usr, provider=provider, use='NEW_ACCOUNT') - send_mp(bot, [usr], _(u'Bienvenue sur {}').format(settings.ZDS_APP['site']['litteral_name']), @@ -876,6 +870,15 @@ def activate_account(request): True, False) token.delete() + + # create an alert for staff if it's a new provider + if usr.email: + provider = re.findall(r'@(.+)', usr.email)[0] + if not NewEmailProvider.objects.filter(provider=provider).exists() \ + and not User.objects.filter(email__endswith='@{}'.format(provider)) \ + .exclude(pk=usr.pk).exists(): + NewEmailProvider.objects.create(user=usr, provider=provider, use='NEW_ACCOUNT') + form = LoginForm(initial={'username': usr.username}) return render(request, 'member/register/token_success.html', {'usr': usr, 'form': form}) From 534f026c4331f56b5451059781884490fd24e0a4 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 6 May 2017 13:54:44 +0200 Subject: [PATCH 31/75] Corrige une faute d'anglais --- update.md | 4 ++-- zds/member/views.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/update.md b/update.md index 8bf7c60c35..b63c4081db 100644 --- a/update.md +++ b/update.md @@ -1048,6 +1048,6 @@ Actions à faire pour mettre en prod la version : v24 ==================================================== Ticket #4313 ------------ +------------ -Via l'admin Django, ajouter la permission `member.change_bannedemailprovider` aux groupes autorisés à gérer les fournisseurs e-mail bannis. \ No newline at end of file ++ Via l'admin Django, ajouter la permission `member.change_bannedemailprovider` aux groupes autorisés à gérer les fournisseurs e-mail bannis. \ No newline at end of file diff --git a/zds/member/views.py b/zds/member/views.py index 5d3431c11e..2bd7d103e7 100644 --- a/zds/member/views.py +++ b/zds/member/views.py @@ -666,7 +666,7 @@ def form_valid(self, form): @login_required @permission_required('member.change_bannedemailprovider', raise_exception=True) def remove_banned_email_provider(request, provider_pk): - """Used to unban a email provider""" + """Used to unban an email provider""" provider = get_object_or_404(BannedEmailProvider, pk=provider_pk) provider.delete() From 071a7f4d38450a0ac896db2b290b62e0c35907ae Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 6 May 2017 18:50:58 +0200 Subject: [PATCH 32/75] PEP-8 --- zds/member/validators.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/zds/member/validators.py b/zds/member/validators.py index efea15fb75..310a3a107d 100644 --- a/zds/member/validators.py +++ b/zds/member/validators.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import os import re from django.contrib.auth.models import User @@ -10,7 +9,6 @@ from django.utils.translation import ugettext_lazy as _ from zds.utils.misc import contains_utf8mb4 -from zds.settings import BASE_DIR from zds.member.models import BannedEmailProvider From e0a185f5422e50478a01b2a9ab628561d9fd2fc1 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Sat, 6 May 2017 19:02:43 +0200 Subject: [PATCH 33/75] =?UTF-8?q?Corrige=20les=20tests=20d=C3=A9j=C3=A0=20?= =?UTF-8?q?existants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zds/member/api/tests.py | 4 +++- zds/member/tests/tests_forms.py | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/zds/member/api/tests.py b/zds/member/api/tests.py index ce890e323a..35cbdf5e9b 100644 --- a/zds/member/api/tests.py +++ b/zds/member/api/tests.py @@ -11,7 +11,7 @@ from zds.api.pagination import REST_PAGE_SIZE, REST_MAX_PAGE_SIZE, REST_PAGE_SIZE_QUERY_PARAM from zds.member.factories import ProfileFactory, StaffProfileFactory, ProfileNotSyncFactory -from zds.member.models import TokenRegister +from zds.member.models import TokenRegister, BannedEmailProvider from rest_framework_extensions.settings import extensions_api_settings from django.core.cache import caches @@ -241,6 +241,8 @@ def test_register_new_user_with_forbidden_email(self): """ Gets an error when the user tries to register a new user with a forbidden email. """ + moderator = StaffProfileFactory().user + BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) data = { 'username': 'Clem', 'email': 'clem@yopmail.com', diff --git a/zds/member/tests/tests_forms.py b/zds/member/tests/tests_forms.py index a8fb7ae9b8..a3354f6b13 100644 --- a/zds/member/tests/tests_forms.py +++ b/zds/member/tests/tests_forms.py @@ -4,6 +4,8 @@ from zds.member.factories import ProfileFactory, NonAsciiProfileFactory from zds.member.forms import LoginForm, RegisterForm, MiniProfileForm, ProfileForm, ChangeUserForm, ChangePasswordForm,\ NewPasswordForm, KarmaForm, UsernameAndEmailForm +from zds.member.models import BannedEmailProvider +from zds.member.factories import StaffProfileFactory stringof77chars = 'abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789-----' stringof251chars = u'abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy' \ @@ -109,7 +111,9 @@ def test_empty_spaces_username_register_form(self): form = RegisterForm(data=data) self.assertFalse(form.is_valid()) - def test_forbiden_email_provider_register_form(self): + def test_forbidden_email_provider_register_form(self): + moderator = StaffProfileFactory().user + BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) data = { 'email': 'test@yopmail.com', 'username': 'ZeTester', @@ -308,6 +312,8 @@ def test_already_used_email_user_form(self): self.assertFalse(form.is_valid()) def test_forbidden_email_provider_user_form(self): + moderator = StaffProfileFactory().user + BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) data = { 'username': self.user1.user.username, 'email': 'test@yopmail.com' From 104ef23ddcb9a5f223e4c405b6b1a96acd6e2dbf Mon Sep 17 00:00:00 2001 From: GCodeur Date: Mon, 8 May 2017 14:30:16 +0200 Subject: [PATCH 34/75] Fix sur la hauteur du menu --- assets/scss/components/_header-dropdown.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scss/components/_header-dropdown.scss b/assets/scss/components/_header-dropdown.scss index 710bbefd06..0036d49b99 100644 --- a/assets/scss/components/_header-dropdown.scss +++ b/assets/scss/components/_header-dropdown.scss @@ -107,7 +107,7 @@ padding: 0; .dropdown-list { - max-height: 390px; + max-height: 360px; overflow-x: hidden; overflow-y: auto; From e5af12de01ab595007b489c63bc4bf147ab322a7 Mon Sep 17 00:00:00 2001 From: GCodeur Date: Mon, 8 May 2017 17:34:46 +0200 Subject: [PATCH 35/75] Recherche des membres utilisant un fournisseur --- templates/member/banned_email_providers.html | 3 +- templates/member/members_with_provider.html | 53 ++++++++++++++++++++ zds/member/urls.py | 4 +- zds/member/views.py | 25 ++++++++- 4 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 templates/member/members_with_provider.html diff --git a/templates/member/banned_email_providers.html b/templates/member/banned_email_providers.html index ccd79152c3..c46f32cff3 100644 --- a/templates/member/banned_email_providers.html +++ b/templates/member/banned_email_providers.html @@ -34,7 +34,7 @@ {% trans "Fournisseur" %} {% trans "Modérateur" %} {% trans "Date du bannissement" %}{% trans "Débannir" %}{% trans "Actions" %}