src/cm/models.py
changeset 513 60da0b2cca9f
parent 512 3764ea0fa1bc
child 514 f99c7f7401b0
equal deleted inserted replaced
512:3764ea0fa1bc 513:60da0b2cca9f
   309     objects = ConfigurationManager()
   309     objects = ConfigurationManager()
   310     
   310     
   311     def __unicode__(self):
   311     def __unicode__(self):
   312         return '%s: %s' % (self.key, self.value)    
   312         return '%s: %s' % (self.key, self.value)    
   313     
   313     
   314 ApplicationConfiguration = Configuration.objects     
       
   315 
       
   316 class TextVersionManager(KeyManager):
   314 class TextVersionManager(KeyManager):
   317 
   315 
   318     def duplicate(self, text_version, duplicate_comments=True):
   316     def duplicate(self, text_version, duplicate_comments=True):
   319         old_comment_set = set(text_version.comment_set.all())
   317         old_comment_set = set(text_version.comment_set.all())
   320         text_version.id = None
   318         text_version.id = None
   356 
   354 
   357     mod_posteriori = models.BooleanField(ugettext_lazy('Moderation a posteriori?'), default=True)
   355     mod_posteriori = models.BooleanField(ugettext_lazy('Moderation a posteriori?'), default=True)
   358 
   356 
   359     from django.utils.safestring import mark_safe
   357     from django.utils.safestring import mark_safe
   360 
   358 
   361     category_1 = models.CharField(ugettext_lazy("Label for the first category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #1523f4">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace.") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True, default=ApplicationConfiguration['workspace_category_1'])
   359     category_1 = models.CharField(ugettext_lazy("Label for the first category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #1523f4">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace.") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True)
   362     category_2 = models.CharField(ugettext_lazy("Label for the second category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #f4154f">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace. ") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True, default=ApplicationConfiguration['workspace_category_2'])
   360     category_2 = models.CharField(ugettext_lazy("Label for the second category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #f4154f">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace. ") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True)
   363     category_3 = models.CharField(ugettext_lazy("Label for the third category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #09ff09">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace. ") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True, default=ApplicationConfiguration['workspace_category_3'])
   361     category_3 = models.CharField(ugettext_lazy("Label for the third category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #09ff09">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace. ") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True)
   364     category_4 = models.CharField(ugettext_lazy("Label for the fourth category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #bc39cf">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace. ") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True, default=ApplicationConfiguration['workspace_category_4'])
   362     category_4 = models.CharField(ugettext_lazy("Label for the fourth category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #bc39cf">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace. ") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True)
   365     category_5 = models.CharField(ugettext_lazy("Label for the fifth category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #ffbd08">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace. ") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True, default=ApplicationConfiguration['workspace_category_5'])
   363     category_5 = models.CharField(ugettext_lazy("Label for the fifth category of comments"), help_text=mark_safe(_("Paragraphs including at least one comment of this category will have a vertical bar with this color: ") + '<span style="width: 2px; height: 5px; background-color: #ffbd08">&nbsp;</span><br />' + _("Leave blank to use the value configured for the workspace. ") + '<br />' + _("To disable this category for this text whatever the configuration for the workspace, enter: ") + '<em>none</em>'), max_length=20, null=True, blank=True)
   366 
   364 
   367     text = models.ForeignKey("Text")
   365     text = models.ForeignKey("Text")
   368 
   366 
   369     objects = TextVersionManager()
   367     objects = TextVersionManager()
   370     
   368     
   604             return user
   602             return user
   605         else:
   603         else:
   606             return user_with_email
   604             return user_with_email
   607         
   605         
   608 
   606 
       
   607 ApplicationConfiguration = Configuration.objects     
       
   608 
   609 from cm.utils.mail import send_mail
   609 from cm.utils.mail import send_mail
   610 
   610 
   611 class UserProfile(KeyModel):
   611 class UserProfile(KeyModel):
   612     modified = models.DateTimeField(auto_now=True)
   612     modified = models.DateTimeField(auto_now=True)
   613     created = models.DateTimeField(auto_now_add=True)
   613     created = models.DateTimeField(auto_now_add=True)