bellroy / lesswrong

Less Wrong platform
http://lesswrong.org/
Other
45 stars 23 forks source link

Disable user posts to main, but permit user edits to existing posts in main #557

Closed xrpd closed 8 years ago

xrpd commented 8 years ago

This is intended as an alternate resolution to issue #549. If this resolution is accepted, PR #556 should be rejected.

Function is identical to #556, except that normal users can now also edit existing posts in main. This resolution is more complex however, since Subreddit.can_submit() now, at times, depends on the article being edited/submitted. Subreddit.can_submit (defined in subreddit.py) now takes an additional parameter, a 'thing' which is the target of the submit (by default set to None). If the 'thing' is in the default_sr and the logged in user authored it, then editing is permitted. Link.can_submit() and newlink.html are updated to use Subreddit.can_submit with the extra parameter. The submit data validator VSubmitSR also uses Subreddit.can_submit(), but does not have reference to the target 'thing'. To accommodate this, I made minimal modifications to VSubmitSR and then corrected in POST_submit and POST_edit_promo (the latter is probably not in use in production). There is precedent for this in the post-validator correction of rate limiting in POST_submit.

I tested in the vagrant vm using admin, high karma and low karma users. Tested operations included attempting to create a new article, attempting to edit an existing article, using "save and continue" for an article, switching subreddits as an administrator and as an author (and then testing with other users on the 'moved' article), and promoting as an administrator (and then testing with other users on the 'promoted' article).

cdaloisio commented 8 years ago

Closes #549