From ef3d824b598ea3cb2a4e5443da9b14c5438e32b6 Mon Sep 17 00:00:00 2001 From: Victor Felder Date: Mon, 2 Jan 2017 20:07:02 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20du=20vocabulaire=20utilis?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/tutorialv2/validation/opinions.html | 18 +++++------ templates/tutorialv2/view/content_online.html | 28 ++++++++-------- zds/munin/urls.py | 4 +-- zds/munin/views.py | 32 +++++++++---------- zds/tutorialv2/forms.py | 4 +-- zds/tutorialv2/managers.py | 2 +- .../migrations/0015_auto_20161120_1640.py | 4 +-- zds/tutorialv2/models/models_database.py | 18 +++++++---- zds/tutorialv2/models/models_versioned.py | 4 +-- zds/tutorialv2/tests/tests_opinion_views.py | 5 +-- zds/tutorialv2/views/views_published.py | 6 ++-- zds/tutorialv2/views/views_validations.py | 10 +++--- .../management/commands/load_fixtures.py | 2 +- 13 files changed, 72 insertions(+), 65 deletions(-) diff --git a/templates/tutorialv2/validation/opinions.html b/templates/tutorialv2/validation/opinions.html index 6ccf2d7dd1..6d2be7e7a3 100644 --- a/templates/tutorialv2/validation/opinions.html +++ b/templates/tutorialv2/validation/opinions.html @@ -4,17 +4,17 @@ {% load i18n %} {% block title_base %} - {% trans "Validation des billets" %} + {% trans "Choix des billets" %} {% endblock %} {% block title %} - {% trans "Validation des billets" %} + {% trans "Choix des billets" %} {% endblock %} {% block breadcrumb_base %} -
  • {% trans "Validation des billets" %}
  • +
  • {% trans "Choix des billets" %}
  • {% endblock %} @@ -23,7 +23,7 @@

    {% block headline %} - {% trans "Validation des billets" %} + {% trans "Choix des billets" %} {% if category %} / {{ category.title }} {% endif %} @@ -46,7 +46,7 @@

    {{ headlinesub|safe }}

    {% trans "Titre" %} {% trans "Auteur(s)" %} {% trans "Date dernière publication" %} - {% trans "À déjà été approuvé" %} + {% trans "A déjà été choisi" %} @@ -66,8 +66,8 @@

    {{ headlinesub|safe }}

    {{ content.update_date|format_date:True|capfirst }} - {% if content.sha_approved %} - {% trans "Oui (mise à jour)" %} - diff + {% if content.sha_picked %} + {% trans "Oui (mise à jour)" %} - diff {% else %} {% trans "Non" %} {% endif %} @@ -78,9 +78,9 @@

    {{ headlinesub|safe }}

    {% else %}

    - {% trans "Aucun billet en validation" %} + {% trans "Aucun billet" %}

    {% endif %} {% endblock %}
    -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/templates/tutorialv2/view/content_online.html b/templates/tutorialv2/view/content_online.html index 16c006b359..2785e6d04c 100644 --- a/templates/tutorialv2/view/content_online.html +++ b/templates/tutorialv2/view/content_online.html @@ -33,8 +33,8 @@ {% block extra_link %} - {% if content.promotion_content.get_absolute_url_online %} - + {% if content.converted_to.get_absolute_url_online %} + {% endif %} {% endblock %} @@ -79,14 +79,14 @@

    {% block content %} {% if content.is_opinion %} - {% if content.promotion_content %} + {% if content.converted_to %}
    - {% if content.promotion_content.get_absolute_url_online %} - {% blocktrans with url_article=content.promotion_content.get_absolute_url_online %} + {% if content.converted_to.get_absolute_url_online %} + {% blocktrans with url_article=content.converted_to.get_absolute_url_online %} Ce billet a été promu en article. {% endblocktrans %} {% elif is_staff %} - {% blocktrans with url_article=content.promotion_content.get_absolute_url %} + {% blocktrans with url_article=content.converted_to.get_absolute_url %} Ce billet a été promu en article qui est en cours de validation. {% endblocktrans %} {% endif %} @@ -234,20 +234,20 @@

    {% blocktrans %}Administration{% endblocktrans %}< {% else %} {% if is_staff %} - {% if content.sha_public != content.sha_approved %} + {% if content.sha_public != content.sha_picked %}
  • - - {% trans "Valider le billet" %} + + {% trans "Choisir le billet" %} - {% crispy formValidOpinion %} + {% crispy formPickOpinion %}
  • {% endif %} - {% if not content.promotion_content %} + {% if not content.converted_to %}
  • - - {% trans "Promouvoir en article" %} + + {% trans "Convertir en article" %} - {% crispy formPromotion %} + {% crispy formConvertOpinion %}
  • {% endif %} {% endif %} diff --git a/zds/munin/urls.py b/zds/munin/urls.py index e89efed7af..8176b17ec2 100644 --- a/zds/munin/urls.py +++ b/zds/munin/urls.py @@ -2,7 +2,7 @@ from django.conf.urls import url -from zds.munin.views import total_topics, total_posts, total_mps, total_tutorials, total_articles, total_tribunes +from zds.munin.views import total_topics, total_posts, total_mps, total_tutorials, total_articles, total_opinions urlpatterns = [ @@ -11,5 +11,5 @@ url(r'^total_mps/$', total_mps, name='total_mp'), url(r'^total_tutorials/$', total_tutorials, name='total_tutorial'), url(r'^total_articles/$', total_articles, name='total_articles'), - url(r'^total_tribunes/$', total_tribunes, name='total_tribunes'), + url(r'^total_opinions/$', total_opinions, name='total_opinions'), ] diff --git a/zds/munin/views.py b/zds/munin/views.py index 2b66389693..d1564463b0 100644 --- a/zds/munin/views.py +++ b/zds/munin/views.py @@ -2,7 +2,6 @@ from zds.forum.models import Topic, Post from zds.mp.models import PrivateTopic, PrivatePost from zds.tutorialv2.models.models_database import PublishableContent, ContentReaction -from django.db.models import Q @muninview(config="""graph_title Total Topics @@ -49,18 +48,19 @@ def total_articles(request): ('online', articles.filter(sha_public__isnull=False).count())] -@muninview(config="""graph_title Total Tribunes -graph_vlabel #tribunes -not_promoted.label Not published yet -not_promoted.draw LINE1 -not_promoted.label Not promoted -not_promoted.draw STACK -promoted.label Promoted as articles -promoted.draw STACK""") -def total_tribunes(request): - tribunes = PublishableContent.objects.filter(type='OPINION').all() - return [('not_published', tribunes.filter(sha_public__isnull=True)), - ('not_promoted', tribunes.filter(sha_public__isnull=False) - .filter(Q(promotion_content__isnull=True) | - Q(promotion_content__sha_public__isnull=True)).count()), - ('promoted', tribunes.filter(promotion_content__sha_public__isnull=False).count())] +@muninview(config="""graph_title Total Opinions +graph_vlabel #opinions +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()), + ('featured', opinions.filter(sha_picked__isnull=False).count()), + ('published', opinions.filter(sha_public__isnull=False).count()), + ('converted', opinions.filter(converted_to__sha_public__isnull=False).count())] diff --git a/zds/tutorialv2/forms.py b/zds/tutorialv2/forms.py index c648daf1fa..26a98ef465 100644 --- a/zds/tutorialv2/forms.py +++ b/zds/tutorialv2/forms.py @@ -1128,7 +1128,7 @@ def __init__(self, content, *args, **kwargs): self.helper.form_action = reverse('validation:valid', kwargs={'pk': content.pk, 'slug': content.slug}) self.helper.form_method = 'post' self.helper.form_class = 'modal modal-flex' - self.helper.form_id = 'valid-opinion' + self.helper.form_id = 'pick-opinion' self.helper.layout = Layout( HTML("

    Êtes-vous certain(e) de vouloir valider ce billet ? Il pourra maintenant être présent sur la page " @@ -1155,7 +1155,7 @@ def __init__(self, content, *args, **kwargs): self.helper.form_action = reverse('validation:promote', kwargs={'pk': content.pk, 'slug': content.slug}) self.helper.form_method = 'post' self.helper.form_class = 'modal modal-flex' - self.helper.form_id = 'promote-opinion' + self.helper.form_id = 'convert-opinion' self.helper.layout = Layout( HTML("

    Êtes-vous certain(e) de vouloir promouvoir ce billet en article ?

    "), diff --git a/zds/tutorialv2/managers.py b/zds/tutorialv2/managers.py index 39d7b90a02..344fa4ae2e 100644 --- a/zds/tutorialv2/managers.py +++ b/zds/tutorialv2/managers.py @@ -197,7 +197,7 @@ def get_last_opinions(self): """ home_number = settings.ZDS_APP['opinions']['home_number'] all_contents = self.filter(type='OPINION') \ - .filter(public_version__isnull=False, sha_approved=F('sha_public')) \ + .filter(public_version__isnull=False, sha_picked=F('sha_public')) \ .prefetch_related('authors') \ .prefetch_related('authors__profile') \ .select_related('last_note') \ diff --git a/zds/tutorialv2/migrations/0015_auto_20161120_1640.py b/zds/tutorialv2/migrations/0015_auto_20161120_1640.py index 5f81e11e1c..a63c9ebb0a 100644 --- a/zds/tutorialv2/migrations/0015_auto_20161120_1640.py +++ b/zds/tutorialv2/migrations/0015_auto_20161120_1640.py @@ -14,12 +14,12 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name='publishablecontent', - name='promotion_content', + name='converted_to', field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, verbose_name='Contenu promu', blank=True, to='tutorialv2.PublishableContent', null=True), ), migrations.AddField( model_name='publishablecontent', - name='sha_approved', + name='sha_picked', field=models.CharField(db_index=True, max_length=80, null=True, verbose_name=b'Sha1 de la version approuv\xc3\xa9e (contenus avec publication sans validation)', blank=True), ), migrations.AlterField( diff --git a/zds/tutorialv2/models/models_database.py b/zds/tutorialv2/models/models_database.py index 5a88afa165..58f28b27bb 100644 --- a/zds/tutorialv2/models/models_database.py +++ b/zds/tutorialv2/models/models_database.py @@ -99,8 +99,8 @@ class Meta: blank=True, null=True, max_length=80, db_index=True) sha_draft = models.CharField('Sha1 de la version de rédaction', blank=True, null=True, max_length=80, db_index=True) - sha_approved = models.CharField('Sha1 de la version approuvée (contenus avec publication sans validation)', - blank=True, null=True, max_length=80, db_index=True) + sha_picked = models.CharField('Sha1 de la version choisie (contenus publiés sans validation)', + blank=True, null=True, max_length=80, db_index=True) beta_topic = models.ForeignKey(Topic, verbose_name='Sujet beta associé', default=None, blank=True, null=True) licence = models.ForeignKey(Licence, verbose_name='Licence', @@ -127,9 +127,15 @@ class Meta: public_version = models.ForeignKey( 'PublishedContent', verbose_name=u'Version publiée', blank=True, null=True, on_delete=models.SET_NULL) - # used for opinion to article promotion to keep an history and add canonical link - promotion_content = models.ForeignKey( - 'self', verbose_name=u'Contenu promu', blank=True, null=True, on_delete=models.SET_NULL) + # FK to an opinion which has been converted to article. Useful to keep track of history and + # to add a canonical link + converted_to = models.ForeignKey( + 'self', + verbose_name=u'Contenu promu', + blank=True, + null=True, + on_delete=models.SET_NULL, + related_name='converted_from') objects = PublishableContentManager() @@ -342,7 +348,7 @@ def insert_data_in_versioned(self, versioned): attrs = [ 'pk', 'authors', 'subcategory', 'image', 'creation_date', 'pubdate', 'update_date', 'source', - 'sha_draft', 'sha_beta', 'sha_validation', 'sha_public', 'sha_approved', 'promotion_content', 'type' + 'sha_draft', 'sha_beta', 'sha_validation', 'sha_public', 'sha_picked', 'converted_to', 'type' ] fns = [ diff --git a/zds/tutorialv2/models/models_versioned.py b/zds/tutorialv2/models/models_versioned.py index 81292c19a1..bb145e6a30 100644 --- a/zds/tutorialv2/models/models_versioned.py +++ b/zds/tutorialv2/models/models_versioned.py @@ -1047,7 +1047,7 @@ class VersionedContent(Container, TemplatableContentModelMixin): sha_beta = None sha_public = None sha_validation = None - sha_approved = None + sha_picked = None is_beta = False is_validation = False is_public = False @@ -1063,7 +1063,7 @@ class VersionedContent(Container, TemplatableContentModelMixin): update_date = None source = None antispam = True - promotion_content = None + converted_to = None content_type_attribute = "type" def __init__(self, current_version, _type, title, slug, slug_repository=''): diff --git a/zds/tutorialv2/tests/tests_opinion_views.py b/zds/tutorialv2/tests/tests_opinion_views.py index be8127e534..3f9cecd3f2 100644 --- a/zds/tutorialv2/tests/tests_opinion_views.py +++ b/zds/tutorialv2/tests/tests_opinion_views.py @@ -335,9 +335,10 @@ def test_opinion_validation(self): follow=False) self.assertEqual(result.status_code, 302) - def test_opinion_promotion(self): + def test_opinion_conversion(self): """ - Test the promotion of PublishableContent where type is OPINION. + Test the conversion of PublishableContent with type=OPINION + to PublishableContent with type=ARTICLE """ text_publication = u'Aussi tôt dit, aussi tôt fait !' diff --git a/zds/tutorialv2/views/views_published.py b/zds/tutorialv2/views/views_published.py index a8534b371c..242607e37d 100644 --- a/zds/tutorialv2/views/views_published.py +++ b/zds/tutorialv2/views/views_published.py @@ -108,9 +108,9 @@ def get_context_data(self, **kwargs): context['next_article'] = all_articles[position + 1] if self.versioned_object.type == 'OPINION': - context['formValidOpinion'] = OpinionValidationForm( + context['formPickOpinion'] = OpinionValidationForm( self.versioned_object, initial={'version': self.versioned_object.sha_public}) - context['formPromotion'] = PromoteOpinionToArticleForm( + context['formConvertOpinion'] = PromoteOpinionToArticleForm( self.versioned_object, initial={'version': self.versioned_object.sha_public}) # pagination of comments @@ -325,7 +325,7 @@ def get_queryset(self): if self.current_content_type: queryset = queryset.filter(content_type=self.current_content_type) else: - queryset = queryset.filter(content__sha_approved=F('sha_public')) + queryset = queryset.filter(content__sha_picked=F('sha_public')) # prefetch: queryset = queryset\ diff --git a/zds/tutorialv2/views/views_validations.py b/zds/tutorialv2/views/views_validations.py index 437f9c71ee..d775578613 100644 --- a/zds/tutorialv2/views/views_validations.py +++ b/zds/tutorialv2/views/views_validations.py @@ -109,7 +109,7 @@ class ValidationOpinionListView(LoginRequiredMixin, PermissionRequiredMixin, Lis subcategory = None queryset = PublishableContent.objects\ .filter(type='OPINION', sha_public__isnull=False)\ - .exclude(sha_approved=F('sha_public')) + .exclude(sha_picked=F('sha_public')) class AskValidationForContent(LoggedWithReadWriteHability, SingleContentFormViewMixin): @@ -609,7 +609,7 @@ def form_valid(self, form): unpublish_content(self.object) self.object.sha_public = None - self.object.sha_approved = None + self.object.sha_picked = None self.object.pubdate = None self.object.save() @@ -663,7 +663,7 @@ def form_valid(self, form): versioned = self.versioned_object self.success_url = versioned.get_absolute_url_online() - db_object.sha_approved = form.cleaned_data['version'] + db_object.sha_picked = form.cleaned_data['version'] db_object.save() msg = render_to_string( @@ -731,8 +731,8 @@ def form_valid(self, form): db_object.public_version = None db_object.save() - # add information of the promotion on the original opinion - opinion.promotion_content = db_object + # add information about the conversion to the original opinion + opinion.converted_to = db_object opinion.save() # add M2M objects diff --git a/zds/utils/management/commands/load_fixtures.py b/zds/utils/management/commands/load_fixtures.py index 7e55ca5fc8..f5747167ce 100644 --- a/zds/utils/management/commands/load_fixtures.py +++ b/zds/utils/management/commands/load_fixtures.py @@ -504,7 +504,7 @@ def load_contents(cli, _type, size, fake): if to_do >= 1: content.sha_public = content.sha_draft if to_do == 1: - content.sha_approved = content.sha_draft + content.sha_picked = content.sha_draft published = publish_content(content, versioned) content.public_version = published content.save()