Repository: zestedesavoir/zds-site

Issue:
Tentative de signalement de faute, et rejet
J'ai essayé de signaler une faute dans le tuto Arduino en préprod, on m'a proposé de faire un MP si mon message est trop long, ce que j'ai fais.

Par contre, le titre du MP est rempli automatiquement et est donc super long :  `Je voudrais signaler une faute dans le tutoriel "Arduino : Premiers pas en informatique embarquée"`

Quand je fini de taper mon message, à la validation, celui-ci est refusé parce que le titre est trop long. Il faut que le titre soit écourté automatiquement.



Discussion:
> Il faut que le titre soit écourté automatiquement.

Jamais. Il faut adapter le texte et les limites de champs pour que ça rentre correctement.

Le texte dépend du titre du tutoriel aussi. Donc quelqu'un devra couper le texte de toute façon.


Resolving patch:
diff --git a/zds/mp/migrations/0004_auto__chg_field_privatetopic_title.py b/zds/mp/migrations/0004_auto__chg_field_privatetopic_title.py
new file mode 100644
--- /dev/null
+++ b/zds/mp/migrations/0004_auto__chg_field_privatetopic_title.py
@@ -0,0 +1,87 @@
+# -*- 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):
+
+        # Changing field 'PrivateTopic.title'
+        db.alter_column(u'mp_privatetopic', 'title', self.gf('django.db.models.fields.CharField')(max_length=130))
+
+    def backwards(self, orm):
+
+        # Changing field 'PrivateTopic.title'
+        db.alter_column(u'mp_privatetopic', 'title', self.gf('django.db.models.fields.CharField')(max_length=80))
+
+    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'mp.privatepost': {
+            'Meta': {'object_name': 'PrivatePost'},
+            'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'privateposts'", 'to': u"orm['auth.User']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'position_in_topic': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
+            'privatetopic': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mp.PrivateTopic']"}),
+            'pubdate': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
+            'text': ('django.db.models.fields.TextField', [], {}),
+            'text_html': ('django.db.models.fields.TextField', [], {}),
+            'update': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
+        },
+        u'mp.privatetopic': {
+            'Meta': {'object_name': 'PrivateTopic'},
+            'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'author'", 'to': u"orm['auth.User']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_message': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'last_message'", 'null': 'True', 'to': u"orm['mp.PrivatePost']"}),
+            'participants': ('django.db.models.fields.related.ManyToManyField', [], {'db_index': 'True', 'related_name': "'participants'", 'symmetrical': 'False', 'to': u"orm['auth.User']"}),
+            'pubdate': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
+            'subtitle': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '130'})
+        },
+        u'mp.privatetopicread': {
+            'Meta': {'object_name': 'PrivateTopicRead'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'privatepost': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mp.PrivatePost']"}),
+            'privatetopic': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mp.PrivateTopic']"}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'privatetopics_read'", 'to': u"orm['auth.User']"})
+        }
+    }
+
+    complete_apps = ['mp']
\ No newline at end of file
diff --git a/zds/mp/models.py b/zds/mp/models.py
--- a/zds/mp/models.py
+++ b/zds/mp/models.py
@@ -13,20 +13,20 @@
 
 class PrivateTopic(models.Model):
 
-    """Topic private, containing private posts."""
+    """
+    Topic private, containing private posts.
+    """
+
     class Meta:
         verbose_name = 'Message privé'
         verbose_name_plural = 'Messages privés'
 
-    title = models.CharField('Titre', max_length=80)
+    title = models.CharField('Titre', max_length=130)
     subtitle = models.CharField('Sous-titre', max_length=200)
-
-    author = models.ForeignKey(User, verbose_name='Auteur',
-                               related_name='author', db_index=True)
-    participants = models.ManyToManyField(User, verbose_name='Participants',
-                                          related_name='participants', db_index=True)
-    last_message = models.ForeignKey('PrivatePost', null=True,
-                                     related_name='last_message',
+    author = models.ForeignKey(User, verbose_name='Auteur',  related_name='author', db_index=True)
+    participants = models.ManyToManyField(User, verbose_name='Participants',  related_name='participants',
+                                          db_index=True)
+    last_message = models.ForeignKey('PrivatePost', null=True, related_name='last_message',
                                      verbose_name='Dernier message')
     pubdate = models.DateTimeField('Date de création', auto_now_add=True, db_index=True)
 


Test patch: