Skip to content

Commit

Permalink
ajoute la référence canonique pour eviter le contenu dupliqué
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jul 7, 2014
1 parent 034ceab commit e7c940a
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 6 deletions.
1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<link rel="stylesheet" href="/static/css/main.css" />
{% else %}
<link rel="stylesheet" href="/static/css/main.min.css" />
{% block source_content %}{% endblock %}
{% endif %}

{# Webfont async loading #}
Expand Down
7 changes: 6 additions & 1 deletion templates/tutorial/base_online.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
&#183; Tutoriels
{% endblock %}

{% block source_content %}
{% if tutorial.source and tutorial.source != "" %}
<link rel="canonical" href="{{tutorial.source}}" />
{% endif %}
{% endblock %}


{% block breadcrumb_base %}
<li><a href="{% url "zds.tutorial.views.index" %}">Tutoriels</a></li>
{% endblock %}
{% endblock %}
23 changes: 22 additions & 1 deletion zds/tutorial/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,15 @@ class AskValidationForm(forms.Form):
}
)
)
source = forms.CharField(
label='Source originale',
required=False,
widget=forms.TextInput(
attrs={
'placeholder': 'Url de la version originale'
}
)
)

def __init__(self, *args, **kwargs):
super(AskValidationForm, self).__init__(*args, **kwargs)
Expand All @@ -355,7 +364,9 @@ def __init__(self, *args, **kwargs):
self.helper.form_method = 'post'

self.helper.layout = Layout(
CommonLayoutModalText(), StrictButton(
CommonLayoutModalText(),
Field('source'),
StrictButton(
'Confirmer',
type='submit'),
Hidden(
Expand All @@ -375,6 +386,15 @@ class ValidForm(forms.Form):
)
)
is_major = forms.BooleanField(label='Version majeure ?', required=False)
source = forms.CharField(
label='Source originale',
required=False,
widget=forms.TextInput(
attrs={
'placeholder': 'Url de la version originale'
}
)
)

def __init__(self, *args, **kwargs):
super(ValidForm, self).__init__(*args, **kwargs)
Expand All @@ -384,6 +404,7 @@ def __init__(self, *args, **kwargs):

self.helper.layout = Layout(
CommonLayoutModalText(),
Field('source'),
Field('is_major'),
StrictButton('Publier', type='submit'),
Hidden('tutorial', '{{ tutorial.pk }}'),
Expand Down
194 changes: 194 additions & 0 deletions zds/tutorial/migrations/0004_auto__add_field_tutorial_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

def forwards(self, orm):
# Adding field 'Tutorial.source'
db.add_column(u'tutorial_tutorial', 'source',
self.gf('django.db.models.fields.CharField')(default='', max_length=200),
keep_default=False)


def backwards(self, orm):
# Deleting field 'Tutorial.source'
db.delete_column(u'tutorial_tutorial', 'source')


models = {
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
u'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'gallery.gallery': {
'Meta': {'object_name': 'Gallery'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'pubdate': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '80'}),
'subtitle': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
'update': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
},
u'gallery.image': {
'Meta': {'object_name': 'Image'},
'gallery': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['gallery.Gallery']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'legend': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True', 'blank': 'True'}),
'physical': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
'pubdate': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '80'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True', 'blank': 'True'}),
'update': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
},
u'tutorial.chapter': {
'Meta': {'object_name': 'Chapter'},
'conclusion': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['gallery.Image']", 'null': 'True', 'blank': 'True'}),
'introduction': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'part': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tutorial.Part']", 'null': 'True', 'blank': 'True'}),
'position_in_part': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
'position_in_tutorial': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '80'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '80', 'blank': 'True'}),
'tutorial': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tutorial.Tutorial']", 'null': 'True', 'blank': 'True'})
},
u'tutorial.extract': {
'Meta': {'object_name': 'Extract'},
'chapter': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tutorial.Chapter']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'position_in_chapter': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
'text': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '80'})
},
u'tutorial.note': {
'Meta': {'object_name': 'Note', '_ormbases': [u'utils.Comment']},
u'comment_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['utils.Comment']", 'unique': 'True', 'primary_key': 'True'}),
'tutorial': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tutorial.Tutorial']"})
},
u'tutorial.part': {
'Meta': {'object_name': 'Part'},
'conclusion': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'introduction': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'position_in_tutorial': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '80'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
'tutorial': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tutorial.Tutorial']"})
},
u'tutorial.tutorial': {
'Meta': {'object_name': 'Tutorial'},
'authors': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.User']", 'db_index': 'True', 'symmetrical': 'False'}),
'conclusion': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'create_at': ('django.db.models.fields.DateTimeField', [], {}),
'description': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'gallery': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['gallery.Gallery']", 'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['gallery.Image']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}),
'images': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'introduction': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'is_locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_note': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_note'", 'null': 'True', 'to': u"orm['tutorial.Note']"}),
'licence': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['utils.Licence']", 'null': 'True', 'blank': 'True'}),
'pubdate': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
'sha_beta': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'}),
'sha_draft': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'}),
'sha_public': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'}),
'sha_validation': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '80'}),
'source': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'subcategory': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['utils.SubCategory']", 'null': 'True', 'db_index': 'True', 'blank': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '10', 'db_index': 'True'}),
'update': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
},
u'tutorial.tutorialread': {
'Meta': {'object_name': 'TutorialRead'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'note': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tutorial.Note']"}),
'tutorial': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tutorial.Tutorial']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tuto_notes_read'", 'to': u"orm['auth.User']"})
},
u'tutorial.validation': {
'Meta': {'object_name': 'Validation'},
'comment_authors': ('django.db.models.fields.TextField', [], {}),
'comment_validator': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'date_proposition': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}),
'date_reserve': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'date_validation': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'status': ('django.db.models.fields.CharField', [], {'default': "'PENDING'", 'max_length': '10'}),
'tutorial': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tutorial.Tutorial']", 'null': 'True', 'blank': 'True'}),
'validator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'author_validations'", 'null': 'True', 'to': u"orm['auth.User']"}),
'version': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'})
},
u'utils.comment': {
'Meta': {'object_name': 'Comment'},
'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'comments'", 'to': u"orm['auth.User']"}),
'dislike': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'editor': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comments-editor'", 'null': 'True', 'to': u"orm['auth.User']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ip_address': ('django.db.models.fields.CharField', [], {'max_length': '39'}),
'is_visible': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'like': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'position': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
'pubdate': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
'text': ('django.db.models.fields.TextField', [], {}),
'text_hidden': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '80'}),
'text_html': ('django.db.models.fields.TextField', [], {}),
'update': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
},
u'utils.licence': {
'Meta': {'object_name': 'Licence'},
'code': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'description': ('django.db.models.fields.TextField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '80'})
},
u'utils.subcategory': {
'Meta': {'object_name': 'SubCategory'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '80'}),
'subtitle': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '80'})
}
}

complete_apps = ['tutorial']
2 changes: 2 additions & 0 deletions zds/tutorial/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Meta:

title = models.CharField('Titre', max_length=80)
description = models.CharField('Description', max_length=200)
source = models.CharField('Source', max_length=200)
authors = models.ManyToManyField(User, verbose_name='Auteurs', db_index=True)

subcategory = models.ManyToManyField(SubCategory,
Expand Down Expand Up @@ -191,6 +192,7 @@ def load_dic(self, mandata):
mandata['subcategory'] = self.subcategory
mandata['image'] = self.image
mandata['pubdate'] = self.pubdate
mandata['source'] = self.source

return mandata

Expand Down
12 changes: 8 additions & 4 deletions zds/tutorial/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def setUp(self):
{
'tutorial': self.bigtuto.pk,
'text': u'Ce tuto est excellent',
'version': self.bigtuto.sha_draft
'version': self.bigtuto.sha_draft,
'source': 'http://zestedesavoir.com',
},
follow=False)
self.assertEqual(pub.status_code, 302)
Expand All @@ -108,7 +109,8 @@ def setUp(self):
{
'tutorial': self.bigtuto.pk,
'text': u'Ce tuto est excellent',
'is_major': True
'is_major': True,
'source': 'http://zestedesavoir.com',
},
follow=False)
self.assertEqual(pub.status_code, 302)
Expand Down Expand Up @@ -1157,7 +1159,8 @@ def setUp(self):
{
'tutorial': self.minituto.pk,
'text': u'Ce tuto est excellent',
'version': self.minituto.sha_draft
'version': self.minituto.sha_draft,
'source': 'http://zestedesavoir.com',
},
follow=False)
self.assertEqual(pub.status_code, 302)
Expand All @@ -1176,7 +1179,8 @@ def setUp(self):
{
'tutorial': self.minituto.pk,
'text': u'Ce tuto est excellent',
'is_major': True
'is_major': True,
'source': 'http://zestedesavoir.com',
},
follow=False)
self.assertEqual(pub.status_code, 302)
Expand Down
Loading

0 comments on commit e7c940a

Please sign in to comment.