Ejemplo n.º 1
0
#
# Author:        alisue
# Date:            2010/11/27
#
# -*- coding: utf-8 -*-
#
# Author:        alisue
# Date:            2010/11/11
#
from django.utils.safestring import mark_safe

from libwaz.contrib.history import site
from libwaz.contrib.history import backends

from models import Material

class MaterialHistoryBackend(backends.BasicHistoryBackend):
    def _post_save_callback(self, *args, **kwargs):
        pass
    def get_message(self, timeline):
        if timeline.action == 'create':
            kwargs = {
                'user': self.get_user(timeline),
                'label': self.get_label(timeline)
            }
            return mark_safe(u"%(user)sさんが「%(label)s」をアップロードしました" % kwargs)
        else:
            return super(MaterialHistoryBackend, self).get_message(timeline)
        
site.register(Material, MaterialHistoryBackend)
Ejemplo n.º 2
0
# -*- coding: utf-8 -*-
#
# Author:        alisue
# Date:            2010/11/27
#
# -*- coding: utf-8 -*-
#
# Author:        alisue
# Date:            2010/11/11
#
from libwaz.contrib.history import site
from libwaz.contrib.history.backends import CommentHistoryBackend
from models import MarkItUpComment

class MarkItUpCommentHistoryBackend(CommentHistoryBackend):
    def autodiscover(self, instance, *args, **kwargs):
        if not instance.is_public:
            return None
        return super(MarkItUpCommentHistoryBackend, self).autodiscover(instance, *args, **kwargs)
site.register(MarkItUpComment, MarkItUpCommentHistoryBackend)
Ejemplo n.º 3
0
# Date:            2010/11/11
#
from django.utils.safestring import mark_safe

from libwaz.contrib.history import site
from libwaz.contrib.history import backends

from models import Event

class EventHistoryBackend(backends.BasicHistoryBackend):
    def _post_save_callback(self, *args, **kwargs):
        pass
    
    def get_message(self, timeline):
        if timeline.action in ('join', 'quit'):
            kwargs = {
                'user': self.get_user(timeline),
                'label': self.get_label(timeline)
            }
            if timeline.action == 'join':
                return mark_safe(u"%(user)sさんが「%(label)s」に参加しました" % kwargs)
            elif timeline.action == 'quit':
                return mark_safe(u"%(user)sさんが「%(label)s」への参加をやめました" % kwargs)
        return super(EventHistoryBackend, self).get_message(timeline)
    
    def autodiscover(self, instance, *args, **kwargs):
        if instance.pub_state == 'draft':
            return None
        super(EventHistoryBackend, self).autodiscover(instance, *args, **kwargs)
site.register(Event, EventHistoryBackend)
Ejemplo n.º 4
0
#
from django.utils.safestring import mark_safe

from libwaz.contrib.history import site
from libwaz.contrib.history import backends

from models import Project

class ProjectHistoryBackend(backends.BasicHistoryBackend):
    def _post_save_callback(self, *args, **kwargs):
        pass
    
    def get_message(self, timeline):
        if timeline.action in ('join', 'quit'):
            kwargs = {
                'user':     self.get_user(timeline),
                'label':    self.get_label(timeline),
            }
            if timeline.action == 'join':
                return mark_safe(u"""%(user)sさんが「%(label)s」に参加しました""" % kwargs)
            elif timeline.action == 'quit':
                return mark_safe(u"""%(user)sさんが「%(label)s」から抜けました""" % kwargs)
        return super(ProjectHistoryBackend, self).get_message(timeline)
    
    def autodiscover(self, instance, *args, **kwargs):
        if instance.pub_state == 'draft':
            return None
        return super(ProjectHistoryBackend, self).autodiscover(instance, *args, **kwargs)
    
site.register(Project, ProjectHistoryBackend)
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
#
# Author:        alisue
# Date:            2010/11/11
#
from django.utils.safestring import mark_safe

from libwaz.contrib.history import site
from libwaz.contrib.history import backends

from models import Entry

class EntryHistoryBackend(backends.BasicHistoryBackend):
    def get_message(self, timeline):
        kwargs = {
            'user':     self.get_user(timeline),
            'label':    self.get_label(timeline),
        }
        if timeline.action == 'create':
            return mark_safe(u"""%(user)sさんが新しく「%(label)s」を書きました""" % kwargs)
        else:
            return super(EntryHistoryBackend, self).get_message(timeline)
    def autodiscover(self, instance, *args, **kwargs):
        if instance.pub_state == 'draft':
            return None
        return super(EntryHistoryBackend, self).autodiscover(instance, *args, **kwargs)
    
site.register(Entry, EntryHistoryBackend)
Ejemplo n.º 6
0
from django.utils.safestring import mark_safe

from libwaz.contrib.history import site
from libwaz.contrib.history import backends

from models import Report

class ReportHistoryBackend(backends.BasicHistoryBackend):
    def _post_save_callback(self, *args, **kwargs):
        pass
    
    def get_message(self, timeline):
        if timeline.action in ('create', 'update', 'delete'):
            return super(ReportHistoryBackend, self).get_message(timeline)
        
        kwargs = {
            'user': self.get_user(timeline),
            'label': self.get_label(timeline)
        }
        if timeline.action == 'charge':
            return mark_safe(u"「%(label)s」の担当者が決定しました" % kwargs)
        elif timeline.action == 'discharge':
            return mark_safe(u"「%(label)s」の担当者が逃げ出しました" % kwargs)
        elif timeline.action == 'resolved':
            return mark_safe(u"「%(label)s」のバグフィクスが完了しました確認してください" % kwargs)
        elif timeline.action == 'verified':
            return mark_safe(u"「%(label)s」のバグフィクスが確認されました" % kwargs)
        elif timeline.action == 'status':
            return mark_safe(u"「%(label)s」のステータスが更新されました" % kwargs)
site.register(Report, ReportHistoryBackend)
Ejemplo n.º 7
0
# -*- coding: utf-8 -*-
#
# Author:        alisue
# Date:            2010/11/11
#
from django.utils.safestring import mark_safe

from libwaz.contrib.history import site
from libwaz.contrib.history import backends

from models import Thread

class ThreadHistoryBackend(backends.BasicHistoryBackend):
    def _post_save_callback(self, **kwargs):
        pass
    def get_message(self, timeline):
        kwargs = {
            'user':     self.get_user(timeline),
            'label':    self.get_label(timeline),
        }
        if timeline.action == 'create':
            return mark_safe(u"""%(user)sさんが新しく「%(label)s」を立てました""" % kwargs)
        else:
            return super(ThreadHistoryBackend, self).get_message(timeline)
    def autodiscover(self, instance, *args, **kwargs):
        if instance.pub_state == 'draft':
            return None
        return super(ThreadHistoryBackend, self).autodiscover(instance, *args, **kwargs)
    
site.register(Thread, ThreadHistoryBackend)
Ejemplo n.º 8
0
from libwaz.contrib.history import backends

from models import Task
from status import STATUSES_DICT

class TaskHistoryBackend(backends.BasicHistoryBackend):
    def _post_save_callback(self, *args, **kwargs):
        pass
    def get_message(self, timeline):
        kwargs = {
            'user':     self.get_user(timeline),
            'label':    self.get_label(timeline),
        }
        if timeline.action == 'create':
            return mark_safe(u"""%(user)sさんが新しく「%(label)s」を発行しました""" % kwargs)
        elif timeline.action == 'join':
            return mark_safe(u"""%(user)sさんが「%(label)s」の担当者に加わりました""" % kwargs)
        elif timeline.action == 'quit':
            return mark_safe(u"""%(user)sさんが「%(label)s」の担当をキャンセルしました""" % kwargs)
        elif timeline.action in ('update', 'delete'):
            return super(TaskHistoryBackend, self).get_message(timeline)
        else:
            kwargs['status'] = STATUSES_DICT[timeline.action].verbose_name
            return mark_safe(u"""「%(label)s」の状態が%(status)sに変更されました""" % kwargs)
        
    def autodiscover(self, instance, *args, **kwargs):
        if instance.pub_state == 'draft':
            return None
        return super(TaskHistoryBackend, self).autodiscover(instance, *args, **kwargs)
site.register(Task, TaskHistoryBackend)