Skip to content
Browse files

Added Error to Stylesheet API on invalid CSS Using new Wiki stylesheets

  • Loading branch information...
1 parent a65a35f commit b4fea95bca4a71a63e3e4cba61d1b5025e0b0cae @nekosune committed Sep 6, 2012
Showing with 6 additions and 0 deletions.
  1. +4 −0 r2/r2/controllers/api.py
  2. +2 −0 r2/r2/controllers/errors.py
View
4 r2/r2/controllers/api.py
@@ -1217,6 +1217,8 @@ def POST_subreddit_stylesheet(self, form, jquery,
form.set_html(".status", _('validation errors'))
form.set_html(".errors ul", ''.join(error_items))
form.find('.errors').show()
+ c.errors.add(errors.BAD_CSS, field = "stylesheet_contents")
+ form.has_errors("stylesheet_contents", errors.BAD_CSS)
return
else:
form.find('.errors').hide()
@@ -1239,6 +1241,8 @@ def POST_subreddit_stylesheet(self, form, jquery,
except ConflictException as e:
form.set_html(".status", _('conflict error'))
form.set_html(".errors ul", _('There was a conflict while editing the stylesheet'))
+ c.errors.add(errors.CSS_CONFLICT, field = "stylesheet_contents")
+ form.has_errors("stylesheet_contents", errors.CSS_CONFLICT)
form.find('#conflict_box').show()
form.set_inputs(conflict_old=e.your,
prevstyle=e.new_id, stylesheet_contents=e.new)
View
2 r2/r2/controllers/errors.py
@@ -92,6 +92,8 @@
('NO_LINKS', _("that reddit only allows text posts")),
('TOO_OLD', _("that's a piece of history now; it's too late to reply to it")),
('BAD_CSS_NAME', _('invalid css name')),
+ ('BAD_CSS',_('invalid css')),
+ ('CSS_CONFLICT',_('css been edited since pageload')),
('TOO_MUCH_FLAIR_CSS', _('too many flair css classes')),
('BAD_FLAIR_TARGET', _('not a valid flair target')),
('OAUTH2_INVALID_CLIENT', _('invalid client id')),

0 comments on commit b4fea95

Please sign in to comment.
Something went wrong with that request. Please try again.