示例#1
0
def action_save_handler(sender, created, instance, **kwargs):
    is_quiet = instance.data is not None and instance.data.get('quiet', False)
    if not created or is_quiet or not instance.public:
        return

    if instance.target:
        send_message(
            key=type(instance.action_object).__name__ + "." + instance.verb,
            message="{user} {verb} «{action_object}» dans «{target}» ({url})",
            user=instance.actor,
            verb=instance.verb,
            action_object=instance.action_object,
            target=instance.target,
            url=settings.ROOT_URL + instance.target.get_absolute_url())
    else:
        if instance.action_object:
            urltosend = settings.ROOT_URL + instance.action_object.get_absolute_url(
            )
        else:
            urltosend = settings.ROOT_URL
        send_message(key=type(instance.action_object).__name__ + "." +
                     instance.verb,
                     message="{user} {verb} «{action_object}» ({url})",
                     user=instance.actor,
                     verb=instance.verb,
                     action_object=instance.action_object,
                     url=urltosend)
示例#2
0
文件: models.py 项目: betz/incubator
def action_save_handler(sender, created, instance, **kwargs):
    is_quiet = instance.data is not None and instance.data.get('quiet', False)
    if not created or is_quiet or not instance.public:
        return

    if instance.target:
        send_message(
            key=type(instance.action_object).__name__ + "." + instance.verb,
            message="{user} {verb} «{action_object}» dans «{target}» ({url})",
            user=instance.actor,
            verb=instance.verb,
            action_object=instance.action_object,
            target=instance.target,
            url=settings.ROOT_URL + instance.target.get_absolute_url()
        )
    else:
        if instance.action_object:
            urltosend = settings.ROOT_URL + instance.action_object.get_absolute_url()
        else:
            urltosend = settings.ROOT_URL
        send_message(
            key=type(instance.action_object).__name__ + "." + instance.verb,
            message="{user} {verb} «{action_object}» ({url})",
            user=instance.actor,
            verb=instance.verb,
            action_object=instance.action_object,
            url=urltosend
        )
示例#3
0
def wiki_save_handler(sender, created, instance, **kwargs):
    if not created:
        return

    path = str(instance.article.urlpath_set.first())
    # Root node is presented as "(root)" but may be localized
    if path[0] == '(' and path[-1] == ')':
        path = ''
    url = settings.ROOT_URL + "/wiki/" + path

    send_message(key='wiki.revision',
                 message="{user} a édité la page «{title}» du wiki ({url})",
                 user=instance.user,
                 title=instance.title,
                 url=url)
示例#4
0
文件: models.py 项目: betz/incubator
def wiki_save_handler(sender, created, instance, **kwargs):
    if not created:
        return

    path = str(instance.article.urlpath_set.first())
    # Root node is presented as "(root)" but may be localized
    if path[0] == '(' and path[-1] == ')':
        path = ''
    url = settings.ROOT_URL + "/wiki/" + path

    send_message(
        key='wiki.revision',
        message="{user} a édité la page «{title}» du wiki ({url})",
        user=instance.user,
        title=instance.title,
        url=url
    )
示例#5
0
def export_pad(request, pk):
    event = get_object_or_404(Event, pk=pk)
    meeting = event.meeting
    if not meeting:
        return HttpResponseForbidden("This is not a meeting")
    if not meeting.OJ:
        return HttpResponseForbidden("This meeting has no OJ")
    if meeting.PV:
        return HttpResponseForbidden("This meeting is already finished")
    if meeting.ongoing:
        return HttpResponseForbidden("This meeting is already ongoing")

    meeting.set_pad_contents(meeting.OJ)
    send_message(key="meeting.start",
                 message="On lance la réunion ! Pad: {url}",
                 url=meeting.pad)
    meeting.ongoing = True
    meeting.save()
    return HttpResponseRedirect(event.get_absolute_url())
示例#6
0
def export_pad(request, pk):
    event = get_object_or_404(Event, pk=pk)
    meeting = event.meeting
    if not meeting:
        return HttpResponseForbidden("This is not a meeting")
    if not meeting.OJ:
        return HttpResponseForbidden("This meeting has no OJ")
    if meeting.PV:
        return HttpResponseForbidden("This meeting is already finished")
    if meeting.ongoing:
        return HttpResponseForbidden("This meeting is already ongoing")

    meeting.set_pad_contents(meeting.OJ)
    send_message(key="meeting.start",
                 message="On lance la réunion ! Pad: {url}",
                 url=meeting.pad)
    meeting.ongoing = True
    meeting.save()
    return HttpResponseRedirect(event.get_absolute_url())
示例#7
0
def wiki_save_handler(sender, created, instance, **kwargs):
    if not created:
        return

    path = str(instance.article.urlpath_set.first())
    # Root node is presented as "(root)" but may be localized
    if path[0] == '(' and path[-1] == ')':
        path = ''
    url = settings.ROOT_URL + "/wiki/" + path

    if url:
        message = "{user} a édité la page «{title}» du wiki ({url})"
    else:
        message = "{user} a créé la page «{title}» sur le wiki"

    send_message(key='wiki.revision',
                 message=message,
                 user=instance.user,
                 title=instance.title,
                 url=url)
    # Add an actream line
    action.send(instance.user, verb='a édité', action_object=instance.article)
示例#8
0
def wiki_save_handler(sender, created, instance, **kwargs):
    if not created:
        return

    path = str(instance.article.urlpath_set.first())
    # Root node is presented as "(root)" but may be localized
    if path[0] == '(' and path[-1] == ')':
        path = ''
    url = settings.ROOT_URL + "/wiki/" + path

    if url:
        message = "{user} a édité la page «{title}» du wiki ({url})"
    else:
        message = "{user} a créé la page «{title}» sur le wiki"

    send_message(
        key='wiki.revision',
        message=message,
        user=instance.user,
        title=instance.title,
        url=url
    )
    # Add an actream line
    action.send(instance.user, verb='a édité', action_object=instance.article)