Skip to content

Commit

Permalink
Amélioration du vocabulaire utilisé
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed Jan 2, 2017
1 parent 66f0093 commit ef3d824
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 65 deletions.
18 changes: 9 additions & 9 deletions templates/tutorialv2/validation/opinions.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<li>{% trans "Validation des billets" %}</li>
<li>{% trans "Choix des billets" %}</li>
{% endblock %}


Expand All @@ -23,7 +23,7 @@
<section class="full-content-wrapper">
<h1>
{% block headline %}
{% trans "Validation des billets" %}
{% trans "Choix des billets" %}
{% if category %}
/ {{ category.title }}
{% endif %}
Expand All @@ -46,7 +46,7 @@ <h2 class="subtitle">{{ headlinesub|safe }}</h2>
<th>{% trans "Titre" %}</th>
<th>{% trans "Auteur(s)" %}</th>
<th>{% trans "Date dernière publication" %}</th>
<th>{% trans "À déjà été approuvé" %}</th>
<th>{% trans "A déjà été choisi" %}</th>
</tr>
</thead>
<tbody>
Expand All @@ -66,8 +66,8 @@ <h2 class="subtitle">{{ headlinesub|safe }}</h2>
<span>{{ content.update_date|format_date:True|capfirst }}</span>
</td>
<td>
{% if content.sha_approved %}
{% trans "Oui (mise à jour)" %} - <a href="{% url 'content:diff' content.pk content.slug %}?from={{ content.sha_approved }}&to={{ content.sha_public }}">diff</a>
{% if content.sha_picked %}
{% trans "Oui (mise à jour)" %} - <a href="{% url 'content:diff' content.pk content.slug %}?from={{ content.sha_picked }}&to={{ content.sha_public }}">diff</a>
{% else %}
{% trans "Non" %}
{% endif %}
Expand All @@ -78,9 +78,9 @@ <h2 class="subtitle">{{ headlinesub|safe }}</h2>
</table>
{% else %}
<p>
{% trans "Aucun billet en validation" %}
{% trans "Aucun billet" %}
</p>
{% endif %}
{% endblock %}
</section>
{% endblock %}
{% endblock %}
28 changes: 14 additions & 14 deletions templates/tutorialv2/view/content_online.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@


{% block extra_link %}
{% if content.promotion_content.get_absolute_url_online %}
<link rel="canonical" href="{{ content.promotion_content.get_absolute_url_online }}" />
{% if content.converted_to.get_absolute_url_online %}
<link rel="canonical" href="{{ content.converted_to.get_absolute_url_online }}" />
{% endif %}
{% endblock %}

Expand Down Expand Up @@ -79,14 +79,14 @@ <h2 class="subtitle" itemprop="description">
{% block content %}

{% if content.is_opinion %}
{% if content.promotion_content %}
{% if content.converted_to %}
<div class="alert-box info">
{% 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 <a href="{{ url_article }}">article</a>.
{% 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 <a href="{{ url_article }}">article</a> qui est en cours de validation.
{% endblocktrans %}
{% endif %}
Expand Down Expand Up @@ -234,20 +234,20 @@ <h3>{% blocktrans %}Admin<span class="wide">istration</span>{% endblocktrans %}<
</li>
{% else %}
{% if is_staff %}
{% if content.sha_public != content.sha_approved %}
{% if content.sha_public != content.sha_picked %}
<li>
<a href="#valid-opinion" class="ico-after open-modal tick green">
{% trans "Valider le billet" %}
<a href="#pick-opinion" class="ico-after open-modal tick green">
{% trans "Choisir le billet" %}
</a>
{% crispy formValidOpinion %}
{% crispy formPickOpinion %}
</li>
{% endif %}
{% if not content.promotion_content %}
{% if not content.converted_to %}
<li>
<a href="#promote-opinion" class="ico-after open-modal tick green">
{% trans "Promouvoir en article" %}
<a href="#convert-opinion" class="ico-after open-modal tick green">
{% trans "Convertir en article" %}
</a>
{% crispy formPromotion %}
{% crispy formConvertOpinion %}
</li>
{% endif %}
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions zds/munin/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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'),
]
32 changes: 16 additions & 16 deletions zds/munin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())]
4 changes: 2 additions & 2 deletions zds/tutorialv2/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<p>Êtes-vous certain(e) de vouloir valider ce billet ? Il pourra maintenant être présent sur la page "
Expand All @@ -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("<p>Êtes-vous certain(e) de vouloir promouvoir ce billet en article ?</p>"),
Expand Down
2 changes: 1 addition & 1 deletion zds/tutorialv2/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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') \
Expand Down
4 changes: 2 additions & 2 deletions zds/tutorialv2/migrations/0015_auto_20161120_1640.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 12 additions & 6 deletions zds/tutorialv2/models/models_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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()

Expand Down Expand Up @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions zds/tutorialv2/models/models_versioned.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=''):
Expand Down
5 changes: 3 additions & 2 deletions zds/tutorialv2/tests/tests_opinion_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 !'
Expand Down
6 changes: 3 additions & 3 deletions zds/tutorialv2/views/views_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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\
Expand Down
10 changes: 5 additions & 5 deletions zds/tutorialv2/views/views_validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion zds/utils/management/commands/load_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ef3d824

Please sign in to comment.