示例#1
0
def createTodoitem(doc, event):
    "generate todoitem when switch document workflow status "

    state = event.new_state.getId()
    # notify designer to view the doc
    node = aq_parent(doc)
    name = doc.title
    sender = doc.creators[0]
    url = doc.absolute_url()

    text = u"""<p>详细情况请点击查看:<a href="%s"><strong>%s</strong></a></p>""" % (
        url, name)
    if state == "pendingview":
        title = u"请查阅下发的文档资料:%s" % name
        title = title.encode("utf-8")

        for id in getDesigners(node):
            notify(
                TodoitemWillCreateEvent(title=title,
                                        userid=id,
                                        sender=sender,
                                        text=text))

    elif state == "pendingprocess":
        title = u"请查阅下发的文档资料:%s,并反馈" % name
        title = title.encode("utf-8")
        for id in self.getDesigner(obj):

            notify(
                TodoitemWillCreateEvent(title=title,
                                        userid=id,
                                        sender=sender,
                                        text=text))
    else:
        pass
示例#2
0
def AssignCreate(doc, event):
    "assign the selected user to a local roles and send todoitem notify"

    state = event.new_state.getId()
    # notify designer to view the doc

    if state == "pendingview":
        users = doc.users
        creator = doc.creators[0]
        name = doc.title
        url = doc.absolute_url()
        text = u"""<p>详细情况请点击查看:<a href="%s"><strong>%s</strong></a></p>""" % (
            url, name)
        title = u"请查阅下发的文档资料:%s" % name
        title = title.encode("utf-8")
        pjt = getProject(doc)
        for id in users:
            # assign Reader to users
            pjt.manage_setLocalRoles(id, ['ProjectReader'])
            #             doc.manage_setLocalRoles(id, ['ProjectReader'])
            # send create todoitem event
            notify(
                TodoitemWillCreateEvent(title=title,
                                        userid=id,
                                        sender=creator,
                                        text=text))
        doc.reindexObject()

    elif state == "pendingprocess":
        old = event.old_state.getId()
        users = doc.users
        creator = doc.creators[0]
        name = safe_unicode(doc.title)
        url = doc.absolute_url()
        text = u"""<p>详细情况请点击查看:<a href="%s"><strong>%s</strong></a></p>""" % (
            url, name)
        if old != "review":
            title = u"请查阅下发的文档资料:%s,及时填写并反馈" % name
        else:
            title = u"请再次查阅下发的文档资料:%s,参考审阅意见,及时完善并反馈" % name
        title = title.encode("utf-8")
        pjt = getProject(doc)
        for id in users:
            # assign Reader to users
            pjt.manage_setLocalRoles(id, ['Editor', 'ProjectReader'])
            #             doc.manage_setLocalRoles(id, ['Editor','ProjectReader'])
            api.user.grant_roles(username=id, roles=['Reader'])
            # send create todoitem event
            notify(
                TodoitemWillCreateEvent(title=title,
                                        userid=id,
                                        sender=creator,
                                        text=text))
    else:
        pass
示例#3
0
 def send_warning(self,percentage):
     "send warning to administrators"
     title = "警告:系统日志已达到%s临界点!" % percentage
     userid = 'test17'
     url = ''
     text = u"""<p>请通过<a href="%s"><strong>日志管理页面</strong></a>提前备份日志</p>""" %(url)
     notify(TodoitemWillCreateEvent(title=title,userid=userid,sender="System",text=text))       
示例#4
0
 def sendTodoitem(self, title, userid, text):
     """parameters:
     title:todoitem 's title,
     userid:will create todoitem in the user's workspace,
     text:rich text description of todoitem
     """
     event.notify(TodoitemWillCreateEvent(title=title, userid=id,
                                          text=text))
示例#5
0
def Review(doc, event):
    "handler from status:pendingview to published or pendingprocess to review"

    state = event.new_state.getId()
    #     import pdb
    #     pdb.set_trace()
    if state == "pendingview":
        old = event.old_state.getId()
        id = doc.creators[0]
        sender = api.user.get_current().id
        name = safe_unicode(doc.title)
        url = doc.absolute_url()
        text = u"""<p>详细情况请点击查看:<a href="%s"><strong>%s</strong></a></p>""" % (
            url, name)
        if old == "pendingview":
            name = u"我已阅读了文档:%s" % name
            title = name.encode("utf-8")
            notify(
                TodoitemWillCreateEvent(title=title,
                                        userid=id,
                                        sender=sender,
                                        text=text))
    if state == "review":
        old = event.old_state.getId()
        id = doc.creators[0]
        sender = api.user.get_current().id
        name = safe_unicode(doc.title)
        url = doc.absolute_url()
        text = u"""<p>详细情况请点击查看:<a href="%s"><strong>%s</strong></a></p>""" % (
            url, name)
        if old == "pendingprocess":
            name = u"我已编辑了文档:%s" % name
            title = name.encode("utf-8")
            notify(
                TodoitemWillCreateEvent(title=title,
                                        userid=id,
                                        sender=sender,
                                        text=text))
示例#6
0
def sendTodoitem(obj, userid):
    name = obj.title
    url = obj.absolute_url()
    sender = obj.creators[0]

    if ITeam.providedBy(obj):
        title = u"你已经被邀请加入%s项目组" % name
        title = title.encode("utf-8")
        text = u"""<p>详细情况请查看<a href="%s"><strong>%s项目组</strong></a></p>""" % (
            url, name)
    else:
        title = u"你已经被邀请加入%s项目" % name
        title = title.encode("utf-8")
        text = u"""<p>详细情况请查看<a href="%s"><strong>%s项目</strong></a></p>""" % (
            url, name)


#     for id in getDesigners(obj):
    notify(
        TodoitemWillCreateEvent(title=title,
                                userid=userid,
                                sender=sender,
                                text=text))
示例#7
0
def send_warning(percentage,userid,url):
        "send warning to administrators"

        title = "警告:系统日志已达到%.0f%%临界点!" % (percentage *100)
        text = u"""<p>请通过<a href="%s"><strong>日志管理页面</strong></a>提前备份日志</p>""" %(url)
        notify(TodoitemWillCreateEvent(title=title,userid=userid,sender="System",text=text))