Пример #1
0
def index():
    item = application.getItemByUUID(request.args(0))
    if item is None:
        raise HTTP(404)

    short = request.vars.short if request.vars.short is not None else False

    tbl = db.plugin_comment_comment
    tbl.item_id.default = item.unique_id
    form = SQLFORM(tbl,
                   submit_button=T('Comment'),
                   formstyle='bootstrap3_stacked')

    rows = db((tbl.id > 0) & (tbl.item_id == item.unique_id)).select(
        orderby=~tbl.created_on)

    if form.process().accepted:
        response.js = "jQuery('#%s').get(0).reload();" % request.cid
        # send notifications to the users, except the current one
        subject = T("Comments on %s", (item.headline, ))
        # get the comment body
        comment = tbl(form.vars.id)
        message = response.render(
            'plugin_comment/someone_commented.txt',
            dict(item=item, comment=comment, user=auth.user))
        application.notifyCollaborators(item.unique_id, subject, message)

    return dict(form=form, comments=rows, short=short, item=item)
Пример #2
0
def index():
    item = application.getItemByUUID(request.args(0))
    if item is None:
        raise HTTP(404)

    short = request.vars.short if request.vars.short is not None else False

    tbl = db.plugin_comment_comment
    tbl.item_id.default = item.unique_id
    form = SQLFORM(
        tbl,
        submit_button=T('Comment'),
        formstyle='bootstrap3_stacked')

    rows = db(
        (tbl.id > 0) & (tbl.item_id == item.unique_id)
    ).select(orderby=~tbl.created_on)

    if form.process().accepted:
        response.js = "jQuery('#%s').get(0).reload();" % request.cid
        # send notifications to the users, except the current one
        subject = T("Comments on %s", (item.headline,))
        # get the comment body
        comment = tbl(form.vars.id)
        message = response.render(
            'plugin_comment/someone_commented.txt',
            dict(item=item, comment=comment, user=auth.user)
        )
        application.notifyCollaborators(
            item.unique_id,
            subject,
            message
        )

    return dict(form=form, comments=rows, short=short, item=item)
Пример #3
0
def share():
    """
    Show the user's who has access to this item
    """
    item = application.getItemByUUID(request.args(0))
    if item is None:
        raise HTTP(404)

    fld_email = Field('email', 'string', default='')
    fld_perms = Field('perms', 'string', default='owner')
    fld_email.requires = IS_EMAIL()
    form = SQLFORM.factory(
        fld_email,
        fld_perms,
        formstyle='bootstrap3_inline',
        submit_button=T("Share this item"),
        table_name='share')
    if form.process().accepted:
        # search a user by his email addr
        u = db.auth_user(email=form.vars.email)
        if u is not None:
            # create new share
            ct = application.getContentType(item.item_type)
            ct.shareItem(item.unique_id, u, perms=form.vars.perms)
            # notify users
            subject = T("Share of %s", (item.headline,))
            message = response.render(
                'share_email.txt',
                dict(
                    item=item,
                    user=auth.user,
                    t_user=db.auth_user(email=form.vars.email)
                )
            )
            application.notifyCollaborators(
                item.unique_id,
                subject,
                message
            )
            # --
            # close the dialog
            response.js = "$('#metaModal').modal('hide');"
        else:
            # no user with that email
            response.flash = T("The user don't exists on this system")
            form.errors.email = T("The user don't exists on this system")

    return locals()