def api_unfavorite_(request): favorite.remove(request.userid, **{_CONTENT_IDS[request.matchdict['content_type']]: int(request.matchdict['content_id'])}) return { 'success': True }
def api_unfavorite_(request): favorite.remove(request.userid, **{_CONTENT_IDS[request.matchdict['content_type']]: int(request.matchdict['content_id'])}) return { 'success': True }
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,))
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,))
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, ))
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,))
def POST(self, content_type, content_id): favorite.remove(self.user_id, **{_CONTENT_IDS[content_type]: int(content_id)}) return json.dumps({ 'success': True })