def submit_visual_get_(request): if not define.is_vouched_for(request.userid): raise WeasylError("vouchRequired") form = request.web_input(title='', tags=[], description='', imageURL='', baseURL='') if form.baseURL: form.imageURL = urlparse.urljoin(form.baseURL, form.imageURL) return Response( define.webpage( request.userid, "submit/visual.html", [ # Folders folder.select_list(request.userid, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 1000 <= i[0] < 2000], profile.get_user_ratings(request.userid), form, ], title="Visual Artwork"))
def edit_submission_get_(request): form = request.web_input(submitid="", anyway="") form.submitid = define.get_int(form.submitid) detail = submission.select_view(request.userid, form.submitid, ratings.EXPLICIT.code, False, anyway=form.anyway) if request.userid != detail['userid'] and request.userid not in staff.MODS: raise WeasylError('InsufficientPermissions') submission_category = detail['subtype'] // 1000 * 1000 return Response( define.webpage( request.userid, "edit/submission.html", [ # Submission detail detail, # Folders folder.select_list(detail['userid'], "drop/all"), # Subtypes [ i for i in macro.MACRO_SUBCAT_LIST if submission_category <= i[0] < submission_category + 1000 ], profile.get_user_ratings(detail['userid']), ], title="Edit Submission"))
def GET(self): form = web.input(submitid="", anyway="") form.submitid = define.get_int(form.submitid) detail = submission.select_view(self.user_id, form.submitid, ratings.EXPLICIT.code, False, anyway=form.anyway) if self.user_id != detail['userid'] and self.user_id not in staff.MODS: return define.errorpage(self.user_id, errorcode.permission) submission_category = detail['subtype'] // 1000 * 1000 return define.webpage( self.user_id, "edit/submission.html", [ # Submission detail detail, # Folders folder.select_list(detail['userid'], "drop/all"), # Subtypes [ i for i in macro.MACRO_SUBCAT_LIST if submission_category <= i[0] < submission_category + 1000 ], profile.get_user_ratings(detail['userid']), ])
def GET(self): return define.webpage(self.user_id, "submit/literary.html", [ # Folders folder.select_list(self.user_id, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 2000 <= i[0] < 3000], profile.get_user_ratings(self.user_id), ])
def submit_multimedia_get_(request): return Response(define.webpage(request.userid, "submit/multimedia.html", [ # Folders folder.select_list(request.userid, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 3000 <= i[0] < 4000], profile.get_user_ratings(request.userid), ], title="Multimedia Artwork"))
def GET(self): return define.webpage( self.user_id, "manage/folders.html", [ # Folders dropdown folder.select_list(self.user_id, "drop/all"), ])
def submit_literary_get_(request): return Response(define.webpage(request.userid, "submit/literary.html", [ # Folders folder.select_list(request.userid, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 2000 <= i[0] < 3000], profile.get_user_ratings(request.userid), ]))
def submissions_(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) folderid = define.get_int(request.params.get('folderid')) or None backid = request.params.get('backid') nextid = request.params.get('nextid') if not otherid: raise WeasylError("userRecordMissing") elif not request.userid and "h" in define.get_config(otherid): raise WeasylError('noGuests') 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 submissions" % (userprofile['full_name'] if has_fullname else userprofile['username'], ) page = define.common_page_start(request.userid, title=page_title) url_format = "/submissions/{username}?%s{folderquery}".format( username=define.get_sysname(userprofile['username']), folderquery="&folderid=%d" % folderid if folderid else "") result = pagination.PaginatedResult(submission.select_list, submission.select_count, 'submitid', url_format, request.userid, rating, limit=60, otherid=otherid, folderid=folderid, backid=define.get_int(backid), nextid=define.get_int(nextid), profile_page_filter=not folderid) page.append( define.render( 'user/submissions.html', [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), # Relationship profile.select_relation(request.userid, otherid), # Recent submissions result, # Folders folder.select_list(otherid), # Current folder folderid, ])) return Response(define.common_page_end(request.userid, page))
def manage_folders_(request): return Response( define.webpage( request.userid, "manage/folders.html", [ # Folders dropdown folder.select_list(request.userid, "drop/all"), ], title="Submission Folders"))
def GET(self): return define.webpage( self.user_id, "submit/literary.html", [ # Folders folder.select_list(self.user_id, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 2000 <= i[0] < 3000], profile.get_user_ratings(self.user_id), ])
def submit_literary_get_(request): return Response( define.webpage( request.userid, "submit/literary.html", [ # Folders folder.select_list(request.userid, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 2000 <= i[0] < 3000], profile.get_user_ratings(request.userid), ]))
def submit_multimedia_get_(request): return Response( define.webpage( request.userid, "submit/multimedia.html", [ # Folders folder.select_list(request.userid, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 3000 <= i[0] < 4000], profile.get_user_ratings(request.userid), ], title="Multimedia Artwork"))
def submit_visual_get_(request): form = request.web_input(title='', tags=[], description='', imageURL='', baseURL='') if form.baseURL: form.imageURL = urlparse.urljoin(form.baseURL, form.imageURL) return Response(define.webpage(request.userid, "submit/visual.html", [ # Folders folder.select_list(request.userid, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 1000 <= i[0] < 2000], profile.get_user_ratings(request.userid), form, ]))
def GET(self): form = web.input(title='', tags=[], description='', imageURL='', baseURL='') if form.baseURL: form.imageURL = urlparse.urljoin(form.baseURL, form.imageURL) return define.webpage(self.user_id, "submit/visual.html", [ # Folders folder.select_list(self.user_id, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 1000 <= i[0] < 2000], profile.get_user_ratings(self.user_id), form, ])
def submit_literary_get_(request): if not define.is_vouched_for(request.userid): raise WeasylError("vouchRequired") return Response( define.webpage( request.userid, "submit/literary.html", [ # Folders folder.select_list(request.userid, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 2000 <= i[0] < 3000], profile.get_user_ratings(request.userid), ], title="Literary Artwork"))
def GET(self, name=""): form = web.input(userid="", name="", backid=None, nextid=None, folderid=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) folderid = define.get_int(form.folderid) or None 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) 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 submissions" % (userprofile['full_name'] if has_fullname else userprofile['username'],) page = define.common_page_start(self.user_id, title=page_title) url_format = "/submissions/{username}?%s{folderquery}".format( username=define.get_sysname(userprofile['username']), folderquery="&folderid=%d" % folderid if folderid else "") result = pagination.PaginatedResult( submission.select_list, submission.select_count, 'submitid', url_format, self.user_id, rating, 60, otherid=otherid, folderid=folderid, backid=define.get_int(form.backid), nextid=define.get_int(form.nextid), config=config, profile_page_filter=not folderid) page.append(define.render(template.user_submissions, [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), # Relationship profile.select_relation(self.user_id, otherid), # Recent submissions result, # Folders folder.select_list(otherid, "sidebar/all"), # Current folder folderid, ])) return define.common_page_end(self.user_id, page)
def submissions_(request): form = request.web_input(userid="", name="", backid=None, nextid=None, folderid=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) folderid = define.get_int(form.folderid) or None 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)) 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 submissions" % (userprofile['full_name'] if has_fullname else userprofile['username'],) page = define.common_page_start(request.userid, title=page_title) url_format = "/submissions/{username}?%s{folderquery}".format( username=define.get_sysname(userprofile['username']), folderquery="&folderid=%d" % folderid if folderid else "") result = pagination.PaginatedResult( submission.select_list, submission.select_count, 'submitid', url_format, request.userid, rating, 60, otherid=otherid, folderid=folderid, backid=define.get_int(form.backid), nextid=define.get_int(form.nextid), config=config, profile_page_filter=not folderid) page.append(define.render('user/submissions.html', [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), # Relationship profile.select_relation(request.userid, otherid), # Recent submissions result, # Folders folder.select_list(otherid, "sidebar/all"), # Current folder folderid, ])) return Response(define.common_page_end(request.userid, page))
def GET(self): form = web.input(title='', tags=[], description='', imageURL='', baseURL='') if form.baseURL: form.imageURL = urlparse.urljoin(form.baseURL, form.imageURL) return define.webpage( self.user_id, "submit/visual.html", [ # Folders folder.select_list(self.user_id, "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if 1000 <= i[0] < 2000], profile.get_user_ratings(self.user_id), form, ])
def edit_submission_get_(request): form = request.web_input(submitid="", anyway="") form.submitid = define.get_int(form.submitid) detail = submission.select_view(request.userid, form.submitid, ratings.EXPLICIT.code, False, anyway=form.anyway) if request.userid != detail['userid'] and request.userid not in staff.MODS: return Response(define.errorpage(request.userid, errorcode.permission)) submission_category = detail['subtype'] // 1000 * 1000 return Response(define.webpage(request.userid, "edit/submission.html", [ # Submission detail detail, # Folders folder.select_list(detail['userid'], "drop/all"), # Subtypes [i for i in macro.MACRO_SUBCAT_LIST if submission_category <= i[0] < submission_category + 1000], profile.get_user_ratings(detail['userid']), ]))
def api_user_view_(request): # Helper functions for this view. def convert_commission_price(value, options): return d.text_price_symbol(options) + d.text_price_amount(value) def convert_commission_setting(target): if target == "o": return "open" elif target == "s": return "sometimes" elif target == "f": return "filled" elif target == "c": return "closed" else: return None userid = request.userid otherid = profile.resolve_by_login( d.get_sysname(request.matchdict['login'])) user = profile.select_profile(otherid) rating = d.get_rating(userid) o_config = user.pop('config') o_settings = user.pop('settings') if not otherid and "h" in o_config: raise HTTPForbidden( json={ "error": { "code": 200, "text": "Profile hidden from unlogged users.", }, }) user.pop('userid', None) user.pop('commish_slots', None) user['created_at'] = d.iso8601(user.pop('unixtime')) user['media'] = api.tidy_all_media(user.pop('user_media')) user['login_name'] = d.get_sysname(user['username']) user['profile_text'] = markdown(user['profile_text']) user['folders'] = folder.select_list(otherid) commissions = { "details": None, "price_classes": None, "commissions": convert_commission_setting(o_settings[0]), "trades": convert_commission_setting(o_settings[1]), "requests": convert_commission_setting(o_settings[2]) } commission_list = commishinfo.select_list(otherid) if commission_list: commissions['details'] = commission_list['content'] if len(commission_list['class']) > 0: classes = list() for cclass in commission_list['class']: commission_class = {"title": cclass['title']} if len(commission_list['price']) > 0: prices = list() for cprice in (i for i in commission_list['price'] if i['classid'] == cclass['classid']): if 'a' in cprice['settings']: ptype = 'additional' else: ptype = 'base' price = { "title": cprice['title'], "price_min": convert_commission_price(cprice['amount_min'], cprice['settings']), "price_max": convert_commission_price(cprice['amount_min'], cprice['settings']), 'price_type': ptype } prices.append(price) commission_class['prices'] = prices classes.append(commission_class) commissions['price_classes'] = classes user['commission_info'] = commissions user['relationship'] = profile.select_relation(userid, otherid) if userid else None if 'O' in o_config: submissions = collection.select_list(userid, rating, 11, otherid=otherid) more_submissions = 'collections' featured = None elif 'A' in o_config: submissions = character.select_list(userid, rating, 11, otherid=otherid) more_submissions = 'characters' featured = None else: submissions = submission.select_list(userid, rating, 11, otherid=otherid, profile_page_filter=True) more_submissions = 'submissions' featured = submission.select_featured(userid, otherid, rating) if submissions: for sub in submissions: tidy_submission(sub) user['recent_submissions'] = submissions user['recent_type'] = more_submissions if featured: tidy_submission(featured) user['featured_submission'] = featured statistics, show_statistics = profile.select_statistics(otherid) if statistics: statistics.pop('staff_notes') user['statistics'] = statistics if show_statistics else None user_info = profile.select_userinfo(otherid) if user_info: if not user_info['show_age']: user_info['age'] = None user_info.pop('show_age', None) user_info.pop('birthday', None) user_info['location'] = user_info.pop('country', None) user['user_info'] = user_info user['link'] = d.absolutify_url("/~" + user['login_name']) return user
def GET(self): return define.webpage(self.user_id, "manage/folders.html", [ # Folders dropdown folder.select_list(self.user_id, "drop/all"), ])
def manage_folders_(request): return Response(define.webpage(request.userid, "manage/folders.html", [ # Folders dropdown folder.select_list(request.userid, "drop/all"), ]))
def GET(self, login): userid = self.user_id otherid = profile.resolve_by_login(login) user = profile.select_profile(otherid) rating = d.get_rating(userid) u_config = d.get_config(userid) o_config = user.pop('config') o_settings = user.pop('settings') if not otherid and "h" in o_config: return json.dumps({ "error": { "code": 200, "text": "Profile hidden from unlogged users." }}) user.pop('userid', None) user.pop('commish_slots', None) user['created_at'] = d.iso8601(user.pop('unixtime')) user['media'] = api.tidy_all_media(user.pop('user_media')) user['login_name'] = d.get_sysname(user['username']) user['profile_text'] = markdown(user['profile_text']) folders = folder.select_list(otherid, "api/all") if folders: old_folders = folders folders = list() for fldr in (i for i in old_folders if 'parentid' not in i): newfolder = { "folder_id": fldr['folderid'], "title": fldr['title'] } if fldr['haschildren']: subfolders = list() for sub in (i for i in old_folders if 'parentid' in i and i['parentid'] == fldr['folderid']): subfolders.append({ "folder_id": sub['folderid'], "title": sub['title'] }) newfolder['subfolders'] = subfolders folders.append(newfolder) user['folders'] = folders commissions = { "details": None, "price_classes": None, "commissions": self.convert_commission_setting(o_settings[0]), "trades": self.convert_commission_setting(o_settings[1]), "requests": self.convert_commission_setting(o_settings[2]) } commission_list = commishinfo.select_list(otherid) if commission_list: commissions['details'] = commission_list['content'] if len(commission_list['class']) > 0: classes = list() for cclass in commission_list['class']: commission_class = { "title": cclass['title'] } if len(commission_list['price']) > 0: prices = list() for cprice in (i for i in commission_list['price'] if i['classid'] == cclass['classid']): if 'a' in cprice['settings']: ptype = 'additional' else: ptype = 'base' price = { "title": cprice['title'], "price_min": self.convert_commission_price(cprice['amount_min'], cprice['settings']), "price_max": self.convert_commission_price(cprice['amount_min'], cprice['settings']), 'price_type': ptype } prices.append(price) commission_class['prices'] = prices classes.append(commission_class) commissions['price_classes'] = classes user['commission_info'] = commissions user['relationship'] = profile.select_relation(userid, otherid) if userid else None if 'O' in o_config: submissions = collection.select_list( userid, rating, 11, otherid=otherid, options=["cover"], config=u_config) more_submissions = 'collections' featured = None elif 'A' in o_config: submissions = character.select_list( userid, rating, 11, otherid=otherid, options=["cover"], config=u_config) more_submissions = 'characters' featured = None else: submissions = submission.select_list( userid, rating, 11, otherid=otherid, options=["cover"], config=u_config, profile_page_filter=True) more_submissions = 'submissions' featured = submission.select_featured(userid, otherid, rating) if submissions: submissions = map(tidy_submission, submissions) user['recent_submissions'] = submissions user['recent_type'] = more_submissions if featured: featured = tidy_submission(featured) user['featured_submission'] = featured statistics = profile.select_statistics(otherid) if statistics: statistics.pop('staff_notes') user['statistics'] = statistics user_info = profile.select_userinfo(otherid) if user_info: if not user_info['show_age']: user_info['age'] = None user_info.pop('show_age', None) user_info.pop('birthday', None) user_info['location'] = user_info.pop('country', None) user['user_info'] = user_info user['link'] = d.absolutify_url("/~" + user['login_name']) return json.dumps(user)