コード例 #1
0
ファイル: models.py プロジェクト: kawazrepos/Kawaz2nd
 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)
コード例 #2
0
ファイル: models.py プロジェクト: kawazrepos/Kawaz2nd
 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)
コード例 #3
0
ファイル: models.py プロジェクト: kawazrepos/Kawaz2nd
 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)
コード例 #4
0
ファイル: models.py プロジェクト: kawazrepos/Kawaz2nd
 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)
コード例 #5
0
 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)
コード例 #6
0
ファイル: models.py プロジェクト: kawazrepos/Kawaz2nd
 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)
コード例 #7
0
ファイル: models.py プロジェクト: kawazrepos/Kawaz2nd
 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)
コード例 #8
0
ファイル: models.py プロジェクト: kawazrepos/Kawaz2nd
 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)
コード例 #9
0
ファイル: models.py プロジェクト: kawazrepos/Kawaz2nd
 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)
コード例 #10
0
ファイル: models.py プロジェクト: kawazrepos/Kawaz2nd
 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)