1 from django.db import models
2 from django.contrib.auth.models import User
3 from django.utils.translation import ugettext_lazy as _
4 from threadedcomments.models import ThreadedComment
6 # Create your models here.
7 class Character(models.Model):
12 created = models.DateField(auto_now_add=1, verbose_name = _("Creation time"))
13 modified = models.DateField(auto_now=1, verbose_name = _("Modification time"))
14 name = models.CharField(max_length=255, verbose_name = _("Name"))
15 status = models.CharField(max_length=2, choices=STATUS_CHOICES, default='N', verbose_name = _("Status"))
16 player = models.ForeignKey(User, verbose_name = _("Player"))
22 verbose_name = _("Character")
23 verbose_name_plural = _("Characters")
25 class Influence(models.Model):
28 ('U', _('Under discussion')),
29 ('P', _('Processing')),
32 created = models.DateField(auto_now_add=1, verbose_name = _("Creation time"))
33 modified = models.DateField(auto_now=1, verbose_name = _("Modification time"))
35 character = models.ForeignKey(Character, verbose_name = _("Character"))
36 contact = models.CharField(max_length=255, verbose_name = _("Contact Name"))
37 summary = models.CharField(max_length=255, verbose_name = _("Summary"))
38 description = models.TextField(verbose_name = _("Description"))
39 status = models.TextField(max_length=1, choices=STATUS_CHOICES, default='N', verbose_name = _("Status"))
40 longterm = models.BooleanField(default=False, verbose_name = _("Long term"))
42 result = models.TextField(blank=True,verbose_name = _("Result"))
47 def get_comments(self, private):
49 Gets the comments that have been made on this Influence. Each
50 comment gets its reply_form attribute set to a Form appropriate
51 for replying to the comment.
53 If private is True, private comments are included in this list.
55 def quote_reply(comment):
56 return "\n".join(["> " + l for l in comment.comment.split("\n")])
58 # Import here to prevent dependency loop, since forms depends on
60 from forms import get_influence_comment_form
63 comments = ThreadedComment.objects.get_tree(self)
65 comments = ThreadedComment.public.get_tree(self)
67 # Annotate each comment with a proper reply form
68 for comment in comments:
69 initial = { 'comment' : quote_reply(comment) }
70 prefix = "reply-to-%s" % (comment.pk)
71 FormClass = get_influence_comment_form(private, comment)
72 comment.reply_form = FormClass(initial=initial,
77 verbose_name = _("Influence")
78 verbose_name_plural = _("Influences")
80 # vim: set sts=4 sw=4 expandtab: