Exemple #1
0
 def save(self, request=None, action=None, *args, **kwargs):
     created = self.pk is None
     super(Task, self).save(request, *args, **kwargs)
     if action is None:
         site.get_backend(Task).autodiscover(self, created)
     else:
         site.get_backend(Task).autodiscover(self, action)
Exemple #2
0
 def save(self, request=None, action=None, *args, **kwargs):
     created = self.pk is None
     super(Event, self).save(request, *args, **kwargs)
     if created:
         self.members.add(self.author)
     if not action:
         site.get_backend(Event).autodiscover(self, created)
Exemple #3
0
 def quit(self, user, save=True):
     u"""イベントの参加を取りやめる"""
     if user == self.author:
         raise AttributeError(u"Author doesn't allow to quit the event.")
     self.members.remove(user)
     if save:
         self.save(action="quit")
         site.get_backend(Event).autodiscover(self, "quit", user=user)
Exemple #4
0
 def quit(self, user, save=True):
     if user == self.author:
         raise AttributeError("Author doesn't allow to quit the project")
     self.members.remove(user)
     user.groups.remove(self.group)
     if save:
         self.save(request=None, action='quit')
         site.get_backend(Project).autodiscover(self, 'quit', user=user)
 def handle_noargs(self, **options):
     output = []
     # History Timeline
     qs = Timeline.objects.filter(url='')
     remove_list = []
     for timeline in qs:
         try:
             instance = timeline.content_object
             if instance is None:
                 remove_list.append(timeline.pk)
             elif getattr(instance, 'pub_state', 'public') == 'draft':
                 remove_list.append(timeline.pk)
             else:
                 try:
                     backend = site.get_backend(instance.__class__)
                     timeline.url = backend._get_url_from_instance(instance)
                     timeline.save()
                 except exceptions.NotRegistered:
                     # Backendが登録されていないため破棄
                     remove_list.append(timeline.pk)
         except AttributeError:
             remove_list.append(timeline.pk)
     Timeline.objects.filter(pk__in=remove_list).delete()
     # Comment
     qs = MarkItUpComment.objects.all()
     remove_list = []
     for comment in qs:
         try:
             instance = comment.content_object
             if instance is None:
                 remove_list.append(comment.pk)
         except AttributeError:
             remove_list.append(comment.pk)
     MarkItUpComment.objects.filter(pk__in=remove_list).delete()
     return "\n".join(output)
Exemple #6
0
 def save(self, request=None, action=None, *args, **kwargs):
     created = self.pk is None
     if not hasattr(self, 'group') or self.group is None:
         group = Group.objects.create(name=u"project_%s"%self.slug)
         self.group = group
         # Bugwazを自動的に生成する
         bugwaz = BugwazProduct.objects.create(label=self.title, body=self.body, rules=u"", group=self.group)
         self.bugwaz = bugwaz
     super(Project ,self).save(request, *args, **kwargs)
     # 更新履歴登録
     if action is None:
         site.get_backend(Project).autodiscover(self, action if action else created)
     # 作成後処理
     if created:
         self.join(self.author, save=False)
         self.save(request, action='ignore')
     # 全員がちゃんとグループに属していることを保証
     for member in self.members.all():
         member.groups.add(self.group)
Exemple #7
0
 def save(self, request=None, action=None, *args, **kwargs):
     created = self.pk is None
     if self.pk is None and request and request.user.is_authenticated():
         self.author = request.user
     if self.pk is None and request:
         self.ip_address = request.META['REMOTE_ADDR']
     super(Report, self).save(request, *args, **kwargs)
     if action is None:
         site.get_backend(Report).autodiscover(self, created)
     elif action == 'charge':
         if self.charges.count() == 1:
             site.get_backend(Report).autodiscover(self, 'charge')
     elif action == 'discharge':
         if self.charges.count() == 0:
             site.get_backend(Report).autodiscover(self, 'discharge')
     else:
         site.get_backend(Report).autodiscover(self, action)
Exemple #8
0
 def save(self, request=None, action=None, *args, **kwargs):
     created = self.pk is None
     super(Material, self).save(request, *args, **kwargs)
     # 更新履歴登録
     if action is None:
         site.get_backend(Material).autodiscover(self, created)
Exemple #9
0
 def join(self, user, save=True):
     u"""イベントに参加する"""
     self.members.add(user)
     if save:
         self.save(action="join")
         site.get_backend(Event).autodiscover(self, "join", user=user)
Exemple #10
0
 def join(self, user, save=True):
     self.members.add(user)
     user.groups.add(self.group)
     if save:
         self.save(request=None, action='join')
         site.get_backend(Project).autodiscover(self, 'join', user=user)