def favorites_(request): name = request.matchdict.get('name', request.params.get('name', '')) userid = define.get_int(request.params.get('userid')) rating = define.get_rating(request.userid) otherid = profile.resolve(request.userid, userid, name) backid = request.params.get('backid') nextid = request.params.get('nextid') feature = request.params.get('feature', False) # TODO(hyena): Why aren't more of these WeasylErrors? if not otherid: raise WeasylError("userRecordMissing") elif not request.userid and "h" in define.get_config(otherid): raise WeasylError('noGuests') elif request.userid != otherid and 'v' in define.get_config(otherid): raise WeasylError('hiddenFavorites') userprofile = profile.select_profile(otherid, viewer=request.userid) has_fullname = userprofile[ 'full_name'] is not None and userprofile['full_name'].strip() != '' page_title = u"%s's favorites" % (userprofile['full_name'] if has_fullname else userprofile['username'], ) page = define.common_page_start(request.userid, title=page_title) if feature: nextid = define.get_int(nextid) backid = define.get_int(backid) url_format = ("/favorites?userid={userid}&feature={feature}&%s".format( userid=otherid, feature=feature)) id_field = feature + "id" count_function = None if feature == "submit": select_function = favorite.select_submit count_function = favorite.select_submit_count elif feature == "char": select_function = favorite.select_char elif feature == "journal": select_function = favorite.select_journal else: raise httpexceptions.HTTPNotFound() faves = pagination.PaginatedResult(select_function, count_function, id_field, url_format, request.userid, rating, limit=60, otherid=otherid, backid=backid, nextid=nextid) else: faves = { "submit": favorite.select_submit(request.userid, rating, 22, otherid=otherid), "char": favorite.select_char(request.userid, rating, 22, otherid=otherid), "journal": favorite.select_journal(request.userid, rating, 22, otherid=otherid), } page.append( define.render( 'user/favorites.html', [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), # Relationship profile.select_relation(request.userid, otherid), # Feature feature, # Favorites faves, ])) return Response(define.common_page_end(request.userid, page))
def favorites_(request): def _FEATURE(target): if target == "submit": return 10 elif target == "char": return 20 elif target == "journal": return 30 else: return 0 form = request.web_input(userid="", name="", feature="", backid=None, nextid=None) form.name = request.matchdict.get('name', form.name) form.userid = define.get_int(form.userid) config = define.get_config(request.userid) rating = define.get_rating(request.userid) otherid = profile.resolve(request.userid, form.userid, form.name) # TODO(hyena): Why aren't more of these WeasylErrors? if not otherid: raise WeasylError("userRecordMissing") elif not request.userid and "h" in define.get_config(otherid): return Response( define.errorpage(request.userid, errorcode.no_guest_access)) elif request.userid != otherid and 'v' in define.get_config(otherid): return Response( define.errorpage( request.userid, "You cannot view this page because the owner does not allow anyone to see their favorites." )) userprofile = profile.select_profile(otherid, images=True, viewer=request.userid) has_fullname = userprofile[ 'full_name'] is not None and userprofile['full_name'].strip() != '' page_title = u"%s's favorites" % (userprofile['full_name'] if has_fullname else userprofile['username'], ) page = define.common_page_start(request.userid, title=page_title) if form.feature: nextid = define.get_int(form.nextid) backid = define.get_int(form.backid) url_format = ("/favorites?userid={userid}&feature={feature}&%s".format( userid=userprofile['userid'], feature=form.feature)) id_field = form.feature + "id" count_function = None if form.feature == "submit": select_function = favorite.select_submit count_function = favorite.select_submit_count elif form.feature == "char": select_function = favorite.select_char elif form.feature == "journal": select_function = favorite.select_journal else: raise httpexceptions.HTTPNotFound() faves = pagination.PaginatedResult(select_function, count_function, id_field, url_format, request.userid, rating, 60, otherid=otherid, backid=backid, nextid=nextid, config=config) else: faves = { "submit": favorite.select_submit(request.userid, rating, 22, otherid=otherid, config=config), "char": favorite.select_char(request.userid, rating, 22, otherid=otherid, config=config), "journal": favorite.select_journal(request.userid, rating, 22, otherid=otherid, config=config), } page.append( define.render( 'user/favorites.html', [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), # Relationship profile.select_relation(request.userid, otherid), # Feature form.feature, # Favorites faves, ])) return Response(define.common_page_end(request.userid, page))
def favorites_(request): def _FEATURE(target): if target == "submit": return 10 elif target == "char": return 20 elif target == "journal": return 30 else: return 0 form = request.web_input(userid="", name="", feature="", backid=None, nextid=None) form.name = request.matchdict.get('name', form.name) form.userid = define.get_int(form.userid) config = define.get_config(request.userid) rating = define.get_rating(request.userid) otherid = profile.resolve(request.userid, form.userid, form.name) # TODO(hyena): Why aren't more of these WeasylErrors? if not otherid: raise WeasylError("userRecordMissing") elif not request.userid and "h" in define.get_config(otherid): return Response(define.errorpage(request.userid, errorcode.no_guest_access)) elif request.userid != otherid and 'v' in define.get_config(otherid): return Response(define.errorpage( request.userid, "You cannot view this page because the owner does not allow anyone to see their favorites.")) userprofile = profile.select_profile(otherid, images=True, viewer=request.userid) has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != '' page_title = u"%s's favorites" % (userprofile['full_name'] if has_fullname else userprofile['username'],) page = define.common_page_start(request.userid, title=page_title) if form.feature: nextid = define.get_int(form.nextid) backid = define.get_int(form.backid) url_format = ( "/favorites?userid={userid}&feature={feature}&%s".format(userid=userprofile['userid'], feature=form.feature)) id_field = form.feature + "id" count_function = None if form.feature == "submit": select_function = favorite.select_submit count_function = favorite.select_submit_count elif form.feature == "char": select_function = favorite.select_char elif form.feature == "journal": select_function = favorite.select_journal else: raise httpexceptions.HTTPNotFound() faves = pagination.PaginatedResult( select_function, count_function, id_field, url_format, request.userid, rating, 60, otherid=otherid, backid=backid, nextid=nextid, config=config) else: faves = { "submit": favorite.select_submit(request.userid, rating, 22, otherid=otherid, config=config), "char": favorite.select_char(request.userid, rating, 22, otherid=otherid, config=config), "journal": favorite.select_journal(request.userid, rating, 22, otherid=otherid, config=config), } page.append(define.render('user/favorites.html', [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), # Relationship profile.select_relation(request.userid, otherid), # Feature form.feature, # Favorites faves, ])) return Response(define.common_page_end(request.userid, page))
def GET(self, name=""): def _FEATURE(target): if target == "submit": return 10 elif target == "char": return 20 elif target == "journal": return 30 else: return 0 form = web.input(userid="", name="", feature="", backid=None, nextid=None) form.name = name if name else form.name form.userid = define.get_int(form.userid) config = define.get_config(self.user_id) rating = define.get_rating(self.user_id) otherid = profile.resolve(self.user_id, form.userid, form.name) if not otherid: raise WeasylError("userRecordMissing") elif not self.user_id and "h" in define.get_config(otherid): return define.errorpage(self.user_id, errorcode.no_guest_access) elif self.user_id != otherid and 'v' in define.get_config(otherid): return define.errorpage( self.user_id, "You cannot view this page because the owner does not allow anyone to see their favorites.") userprofile = profile.select_profile(otherid, images=True, viewer=self.user_id) has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != '' page_title = u"%s's favorites" % (userprofile['full_name'] if has_fullname else userprofile['username'],) page = define.common_page_start(self.user_id, title=page_title) if form.feature: nextid = define.get_int(form.nextid) backid = define.get_int(form.backid) url_format = ( "/favorites?userid={userid}&feature={feature}&%s".format(userid=userprofile['userid'], feature=form.feature)) id_field = form.feature + "id" count_function = None if form.feature == "submit": select_function = favorite.select_submit count_function = favorite.select_submit_count elif form.feature == "char": select_function = favorite.select_char elif form.feature == "journal": select_function = favorite.select_journal faves = pagination.PaginatedResult( select_function, count_function, id_field, url_format, self.user_id, rating, 60, otherid=otherid, backid=backid, nextid=nextid, config=config) else: faves = { "submit": favorite.select_submit(self.user_id, rating, 22, otherid=otherid, config=config), "char": favorite.select_char(self.user_id, rating, 22, otherid=otherid, config=config), "journal": favorite.select_journal(self.user_id, rating, 22, otherid=otherid, config=config), } page.append(define.render(template.user_favorites, [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), # Relationship profile.select_relation(self.user_id, otherid), # Feature form.feature, # Favorites faves, ])) return define.common_page_end(self.user_id, page)
def GET(self, name=""): def _FEATURE(target): if target == "submit": return 10 elif target == "char": return 20 elif target == "journal": return 30 else: return 0 form = web.input(userid="", name="", feature="", backid=None, nextid=None) form.name = name if name else form.name form.userid = define.get_int(form.userid) config = define.get_config(self.user_id) rating = define.get_rating(self.user_id) otherid = profile.resolve(self.user_id, form.userid, form.name) if not otherid: raise WeasylError("userRecordMissing") elif not self.user_id and "h" in define.get_config(otherid): return define.errorpage(self.user_id, errorcode.no_guest_access) elif self.user_id != otherid and 'v' in define.get_config(otherid): return define.errorpage( self.user_id, "You cannot view this page because the owner does not allow anyone to see their favorites." ) userprofile = profile.select_profile(otherid, images=True, viewer=self.user_id) has_fullname = userprofile[ 'full_name'] is not None and userprofile['full_name'].strip() != '' page_title = u"%s's favorites" % (userprofile['full_name'] if has_fullname else userprofile['username'], ) page = define.common_page_start(self.user_id, title=page_title) if form.feature: nextid = define.get_int(form.nextid) backid = define.get_int(form.backid) url_format = ( "/favorites?userid={userid}&feature={feature}&%s".format( userid=userprofile['userid'], feature=form.feature)) id_field = form.feature + "id" count_function = None if form.feature == "submit": select_function = favorite.select_submit count_function = favorite.select_submit_count elif form.feature == "char": select_function = favorite.select_char elif form.feature == "journal": select_function = favorite.select_journal faves = pagination.PaginatedResult(select_function, count_function, id_field, url_format, self.user_id, rating, 60, otherid=otherid, backid=backid, nextid=nextid, config=config) else: faves = { "submit": favorite.select_submit(self.user_id, rating, 22, otherid=otherid, config=config), "char": favorite.select_char(self.user_id, rating, 22, otherid=otherid, config=config), "journal": favorite.select_journal(self.user_id, rating, 22, otherid=otherid, config=config), } page.append( define.render( template.user_favorites, [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), # Relationship profile.select_relation(self.user_id, otherid), # Feature form.feature, # Favorites faves, ])) return define.common_page_end(self.user_id, page)