Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove storify #744

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8eb489c
remove use of storify in controllers/marketplace.py
sl1-1 Feb 17, 2020
6323a1b
remove dependency on storify for controllers/user.py
sl1-1 Feb 17, 2020
f056fad
remove dependency on storify from controllers/general.py
sl1-1 Feb 17, 2020
f888bcc
remove dependency on storify from controllers/settings.py
sl1-1 Feb 17, 2020
04436ea
remove dependency on storify from controllers/profile.py
sl1-1 Feb 17, 2020
a11727f
remove dependency on storify from controllers/content.py
sl1-1 Feb 17, 2020
e9a241d
remove dependency on storify from controllers/detail.py
sl1-1 Feb 17, 2020
c9e5d58
remove storify from controllers/messages.py
sl1-1 Feb 17, 2020
596c90d
Remove dependency on storify from controllers/interaction.py
sl1-1 Feb 17, 2020
f0c512c
remove dependency on storify from controllers/moderation.py
sl1-1 Feb 17, 2020
2c674ac
remove dependency on storify from controllers/admin.py
sl1-1 Feb 17, 2020
daae586
remove dependency on storify from controllers/director.py
sl1-1 Feb 17, 2020
4e49905
remove dependency on storify from controllers/api.py
sl1-1 Feb 17, 2020
947fa78
remove dependency on storify from controllers/weasyl_collections.py
sl1-1 Feb 17, 2020
6ef7e51
remove storify dependency from oauth2.py
sl1-1 Feb 17, 2020
0684f84
remove web_input_request_method
sl1-1 Feb 17, 2020
e8c49f0
Merge branch 'master' into Remove_storify
sl1-1 Feb 17, 2020
5430fdf
resolve issues detected by LGTM
sl1-1 Feb 17, 2020
4a949b9
Merge branch 'master' into Remove_storify
sl1-1 Feb 28, 2020
e62cb3e
Fix merge issue
sl1-1 Feb 28, 2020
046d200
adjustments as recommended in code review
sl1-1 Mar 4, 2020
795bc9b
Fix test
sl1-1 Mar 4, 2020
6e0eeb1
Update weasyl/controllers/api.py
sl1-1 Mar 7, 2020
5a17484
Apply suggestions from code review
sl1-1 Mar 7, 2020
221f53e
Cleanup
sl1-1 Mar 7, 2020
d81eb54
Apply suggestions from code review
sl1-1 Mar 7, 2020
4c76cc6
More cleanup as recommended by code review
sl1-1 Mar 7, 2020
b0e5236
Merge remote-tracking branch 'remotes/Weasyl/master' into Remove_storify
sl1-1 Mar 7, 2020
7aaa41e
Merge branch 'master' into Remove_storify
sl1-1 Mar 7, 2020
2a599eb
Merge branch 'master' into Remove_storify
charmander Apr 3, 2020
de72c45
Remove last use of weasyl.test.utils.Bag
charmander Apr 3, 2020
222a53e
Merge branch 'master' into Remove_storify
charmander Apr 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions weasyl/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def site_update_put_(request):

@admin_only
def admincontrol_manageuser_get_(request):
form = request.web_input(name="")
otherid = profile.resolve(None, None, form.name)
otherid = profile.resolve(None, None, request.params.get('name', ''))

if not otherid:
raise WeasylError("userRecordMissing")
Expand All @@ -92,32 +91,28 @@ def admincontrol_manageuser_get_(request):
@admin_only
@token_checked
def admincontrol_manageuser_post_(request):
form = request.web_input(ch_username="", ch_full_name="", ch_catchphrase="", ch_email="",
ch_birthday="", ch_gender="", ch_country="", remove_social=[])
userid = d.get_int(form.userid)
userid = d.get_int(request.params.get('userid', ''))

if request.userid != userid and userid in staff.ADMINS and request.userid not in staff.TECHNICAL:
raise WeasylError('InsufficientPermissions')

profile.do_manage(request.userid, userid,
username=form.username.strip() if form.ch_username else None,
full_name=form.full_name.strip() if form.ch_full_name else None,
catchphrase=form.catchphrase.strip() if form.ch_catchphrase else None,
birthday=form.birthday if form.ch_birthday else None,
gender=form.gender if form.ch_gender else None,
country=form.country if form.ch_country else None,
remove_social=form.remove_social,
permission_tag='permission-tag' in form)
username=request.params.get('username', '').strip() if 'ch_username' in request.params else None,
full_name=request.params.get('full_name', '').strip() if 'ch_full_name' in request.params else None,
catchphrase=request.params.get('catchphrase', '').strip() if 'ch_catchphrase' in request.params else None,
birthday=request.params.get('birthday', '') if 'ch_birthday' in request.params else None,
gender=request.params.get('gender', '') if 'ch_gender' in request.params else None,
country=request.params.get('country', '') if 'ch_country' in request.params else None,
remove_social=request.params.getall('remove_social'),
permission_tag='permission-tag' in request.params)
raise HTTPSeeOther(location="/admincontrol")


@admin_only
@token_checked
def admincontrol_acctverifylink_(request):
form = request.web_input(username="", email="")

token = login.get_account_verification_token(
username=form.username, email=form.email)
username=request.params.get('username', ''), email=request.params.get('email', ''))

if token:
return Response(d.webpage(request.userid, "admincontrol/acctverifylink.html", [token]))
Expand Down Expand Up @@ -174,17 +169,28 @@ def admincontrol_finduser_get_(request):
@admin_only
@token_checked
def admincontrol_finduser_post_(request):
form = request.web_input(userid="", username="", email="", excludebanned="", excludesuspended="", excludeactive="",
dateafter="", datebefore="", row_offset=0, ipaddr="")

row_offset = int(request.params.get('row_offset', 0))
# Redirect negative row offsets (PSQL errors on negative offset values)
if int(form.row_offset) < 0:
if row_offset < 0:
raise HTTPSeeOther("/admincontrol/finduser")

form = {
'targetid': request.params.get('targetid', ''),
'username': request.params.get('username', '').strip(),
'email': request.params.get('email', '').strip(),
'excludebanned': request.params.get('excludebanned', ''),
'excludesuspended': request.params.get('excludesuspended', ''),
'excludeactive': request.params.get('excludeactive', ''),
'dateafter': request.params.get('dateafter', ''),
'datebefore': request.params.get('datebefore', ''),
'ipaddr': request.params.get('ipaddr', ''),
'row_offset': row_offset,
}

return Response(d.webpage(request.userid, "admincontrol/finduser.html", [
# Search results
moderation.finduser(request.userid, form),
moderation.finduser(**form),
# Pass the form and row offset in to enable pagination
form,
int(form.row_offset)
row_offset
], title="Search Users: Results"))
40 changes: 17 additions & 23 deletions weasyl/controllers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def inner(request):
@view_config(route_name='useravatar', renderer='json')
@api_method
def api_useravatar_(request):
form = request.web_input(username="")
userid = profile.resolve_by_login(d.get_sysname(form.username))
userid = profile.resolve_by_login(d.get_sysname(request.params.get('username', '')))

if userid:
media_items = media.get_user_media(userid)
Expand Down Expand Up @@ -154,12 +153,12 @@ def tidy_submission(submission):
@view_config(route_name='api_frontpage', renderer='json')
@api_method
def api_frontpage_(request):
form = request.web_input(since=None, count=0)
since = None

try:
if form.since:
since = d.parse_iso8601(form.since)
count = int(form.count)
if 'since' in request.params:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make an empty ?since= will stop working. I think we may as well keep full backwards compatibility here.

since = d.parse_iso8601(request.params['since'])
count = int(request.params.get('count', 0))
except ValueError:
raise HTTPUnprocessableEntity(json=_ERROR_UNEXPECTED)
else:
Expand All @@ -181,28 +180,25 @@ def api_frontpage_(request):
@view_config(route_name='api_submission_view', renderer='json')
@api_method
def api_submission_view_(request):
form = request.web_input(anyway='', increment_views='')
return submission.select_view_api(
request.userid, int(request.matchdict['submitid']),
anyway=bool(form.anyway), increment_views=bool(form.increment_views))
anyway=('anyway' in request.params), increment_views=('increment_views' in request.params))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behaviour difference for empty values ?anyway=, ?increment_views=.

Suggested change
anyway=('anyway' in request.params), increment_views=('increment_views' in request.params))
anyway=bool(request.params.get('anyway')), increment_views=bool(request.params.get('increment_views'))



@view_config(route_name='api_journal_view', renderer='json')
@api_method
def api_journal_view_(request):
form = request.web_input(anyway='', increment_views='')
return journal.select_view_api(
request.userid, int(request.matchdict['journalid']),
anyway=bool(form.anyway), increment_views=bool(form.increment_views))
anyway=('anyway' in request.params), increment_views=('increment_views' in request.params))


@view_config(route_name='api_character_view', renderer='json')
@api_method
def api_character_view_(request):
form = request.web_input(anyway='', increment_views='')
return character.select_view_api(
request.userid, int(request.matchdict['charid']),
anyway=bool(form.anyway), increment_views=bool(form.increment_views))
anyway=('anyway' in request.params), increment_views=('increment_views' in request.params))


@view_config(route_name='api_user_view', renderer='json')
Expand Down Expand Up @@ -365,15 +361,14 @@ def api_user_gallery_(request):
if not userid:
raise WeasylError('userRecordMissing')

form = request.web_input(since=None, count=0, folderid=0, backid=0, nextid=0)
since = None
try:
if form.since:
since = d.parse_iso8601(form.since)
count = int(form.count)
folderid = int(form.folderid)
backid = int(form.backid)
nextid = int(form.nextid)
if 'since' in request.params:
since = d.parse_iso8601(request.params['since'])
count = int(requests.params.get('count', 0))
folderid = int(requests.params.get('folderid', 0))
backid = int(requests.params.get('backid', 0))
nextid = int(requests.params.get('nextid', 0))
sl1-1 marked this conversation as resolved.
Show resolved Hide resolved
except ValueError:
raise HTTPUnprocessableEntity(json=_ERROR_UNEXPECTED)
else:
Expand Down Expand Up @@ -401,11 +396,10 @@ def api_user_gallery_(request):
@api_login_required
@api_method
def api_messages_submissions_(request):
form = request.web_input(count=0, backtime=0, nexttime=0)
try:
count = int(form.count)
backtime = int(form.backtime)
nexttime = int(form.nexttime)
count = int(requests.params.get('count', 0))
backtime = int(requests.params.get('backtime', 0))
nexttime = int(requests.params.get('nexttime', 0))
sl1-1 marked this conversation as resolved.
Show resolved Hide resolved
except ValueError:
raise HTTPUnprocessableEntity(json=_ERROR_UNEXPECTED)
else:
Expand Down
Loading