+
{% crispy formValid %}
diff --git a/zds/tutorial/forms.py b/zds/tutorial/forms.py
index f3143e1e72..86f30a3788 100644
--- a/zds/tutorial/forms.py
+++ b/zds/tutorial/forms.py
@@ -365,6 +365,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)
@@ -373,7 +382,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(
@@ -393,6 +404,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)
@@ -402,6 +422,7 @@ def __init__(self, *args, **kwargs):
self.helper.layout = Layout(
CommonLayoutModalText(),
+ Field('source'),
Field('is_major'),
StrictButton('Publier', type='submit'),
Hidden('tutorial', '{{ tutorial.pk }}'),
diff --git a/zds/tutorial/migrations/0004_auto__add_field_tutorial_source.py b/zds/tutorial/migrations/0004_auto__add_field_tutorial_source.py
new file mode 100644
index 0000000000..55152b1ad7
--- /dev/null
+++ b/zds/tutorial/migrations/0004_auto__add_field_tutorial_source.py
@@ -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']
\ No newline at end of file
diff --git a/zds/tutorial/models.py b/zds/tutorial/models.py
index c431384a13..b718f9e920 100644
--- a/zds/tutorial/models.py
+++ b/zds/tutorial/models.py
@@ -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,
@@ -194,6 +195,7 @@ def load_dic(self, mandata):
mandata['subcategory'] = self.subcategory
mandata['image'] = self.image
mandata['pubdate'] = self.pubdate
+ mandata['source'] = self.source
return mandata
diff --git a/zds/tutorial/tests.py b/zds/tutorial/tests.py
index e624db4506..3fffb17498 100644
--- a/zds/tutorial/tests.py
+++ b/zds/tutorial/tests.py
@@ -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)
@@ -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)
@@ -1171,7 +1173,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)
@@ -1190,7 +1193,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)
diff --git a/zds/tutorial/views.py b/zds/tutorial/views.py
index b60f509248..b010edfc18 100644
--- a/zds/tutorial/views.py
+++ b/zds/tutorial/views.py
@@ -348,6 +348,7 @@ def valid_tutorial(request):
if request.POST.get('is_major', False) or tutorial.sha_public is None:
tutorial.pubdate = datetime.now()
tutorial.sha_public = validation.version
+ tutorial.source = request.POST["source"]
tutorial.sha_validation = None
tutorial.save()
messages.success(request, u"Le tutoriel a bien été validé.")
@@ -449,6 +450,7 @@ def ask_validation(request):
validation.comment_authors = request.POST["text"]
validation.version = request.POST["version"]
validation.save()
+ validation.tutorial.source=request.POST["source"]
validation.tutorial.sha_validation = request.POST["version"]
validation.tutorial.save()
messages.success(request,
@@ -700,7 +702,10 @@ def view_tutorial(request, tutorial_pk, tutorial_slug):
.order_by("-date_proposition")\
.first()
formAskValidation = AskValidationForm()
- formValid = ValidForm()
+ if tutorial.source:
+ formValid = ValidForm(initial={"source": tutorial.source})
+ else:
+ formValid = ValidForm()
formReject = RejectForm()
return render_template("tutorial/tutorial/view.html", {
"tutorial": tutorial,