Esempio n. 1
0
File: api.py Progetto: Weasyl/weasyl
def api_favorite_(request):
    favorite.insert(request.userid,
                    **{_CONTENT_IDS[request.matchdict['content_type']]: int(request.matchdict['content_id'])})

    return {
        'success': True
    }
Esempio n. 2
0
def api_favorite_(request):
    favorite.insert(request.userid,
                    **{_CONTENT_IDS[request.matchdict['content_type']]: int(request.matchdict['content_id'])})

    return {
        'success': True
    }
Esempio n. 3
0
    def POST(self, content_type, content_id):
        try:
            favorite.insert(self.user_id, **{_CONTENT_IDS[content_type]: int(content_id)})
        except WeasylError as we:
            if we.value != 'favoriteRecordExists':
                raise

        return json.dumps({
            'success': True
        })
Esempio n. 4
0
def favorite_(request):
    form = request.web_input(submitid="", charid="", journalid="")
    form.charid = define.get_int(form.charid)
    form.submitid = define.get_int(form.submitid)
    form.journalid = define.get_int(form.journalid)

    if form.action == "favorite":
        favorite.insert(request.userid, form.submitid, form.charid, form.journalid)
    elif form.action == "unfavorite":
        favorite.remove(request.userid, form.submitid, form.charid, form.journalid)

    if form.submitid:
        raise HTTPSeeOther(location="/submission/%i" % (form.submitid,))
    elif form.charid:
        raise HTTPSeeOther(location="/character/%i" % (form.charid,))
    else:
        raise HTTPSeeOther(location="/journal/%i" % (form.journalid,))
Esempio n. 5
0
def create_favorite(userid, **kwargs):
    unixtime = kwargs.pop('unixtime', None)
    favorite.insert(userid, **kwargs)

    if unixtime is not None:
        if 'submitid' in kwargs:
            type_ = 's'
        elif 'charid' in kwargs:
            type_ = 'c'
        elif 'journalid' in kwargs:
            type_ = 'j'

        targetid = d.get_targetid(*kwargs.values())

        fav = content.Favorite.query.filter_by(userid=userid, type=type_, targetid=targetid).one()
        fav.unixtime = unixtime
        content.Favorite.dbsession.flush()
Esempio n. 6
0
    def POST(self):
        form = web.input(submitid="", charid="", journalid="")
        form.charid = define.get_int(form.charid)
        form.submitid = define.get_int(form.submitid)
        form.journalid = define.get_int(form.journalid)

        if form.action == "favorite":
            favorite.insert(self.user_id, form.submitid, form.charid, form.journalid)
        elif form.action == "unfavorite":
            favorite.remove(self.user_id, form.submitid, form.charid, form.journalid)

        if form.submitid:
            raise web.seeother("/submission/%i" % (form.submitid,))
        elif form.charid:
            raise web.seeother("/character/%i" % (form.charid,))
        else:
            raise web.seeother("/journal/%i" % (form.journalid,))
Esempio n. 7
0
def favorite_(request):
    form = request.web_input(submitid="", charid="", journalid="")
    form.charid = define.get_int(form.charid)
    form.submitid = define.get_int(form.submitid)
    form.journalid = define.get_int(form.journalid)

    if form.action == "favorite":
        favorite.insert(request.userid, form.submitid, form.charid,
                        form.journalid)
    elif form.action == "unfavorite":
        favorite.remove(request.userid, form.submitid, form.charid,
                        form.journalid)

    if form.submitid:
        raise HTTPSeeOther(location="/submission/%i" % (form.submitid, ))
    elif form.charid:
        raise HTTPSeeOther(location="/character/%i" % (form.charid, ))
    else:
        raise HTTPSeeOther(location="/journal/%i" % (form.journalid, ))
Esempio n. 8
0
    def POST(self):
        form = web.input(submitid="", charid="", journalid="")
        form.charid = define.get_int(form.charid)
        form.submitid = define.get_int(form.submitid)
        form.journalid = define.get_int(form.journalid)

        if form.action == "favorite":
            try:
                favorite.insert(self.user_id, form.submitid, form.charid, form.journalid)
            except WeasylError as we:
                if we.value != "favoriteRecordExists":
                    raise
        elif form.action == "unfavorite":
            favorite.remove(self.user_id, form.submitid, form.charid, form.journalid)

        if form.submitid:
            raise web.seeother("/submission/%i" % (form.submitid,))
        elif form.charid:
            raise web.seeother("/character/%i" % (form.charid,))
        else:
            raise web.seeother("/journal/%i" % (form.journalid,))
Esempio n. 9
0
File: api.py Progetto: hyena/weasyl
    def POST(self, content_type, content_id):
        favorite.insert(self.user_id, **{_CONTENT_IDS[content_type]: int(content_id)})

        return json.dumps({
            'success': True
        })