'Update a subreddit\'s stylesheet.
`op` should be `save` to update the contents of the stylesheet.'

@require_oauth2_scope('modconfig')
@validatedForm(VSrModerator(perms='config'), VModhash(), stylesheet_contents=nop('stylesheet_contents', docs={'stylesheet_contents': 'the    new    stylesheet    content'}), reason=VPrintable('reason', 256, empty_error=None), op=VOneOf('op', ['save', 'preview']))
@api_doc(api_section.subreddits, uses_site=True)
def POST_subreddit_stylesheet(self, form, jquery, stylesheet_contents='', prevstyle='', op='save', reason=None):

    if g.css_killswitch:
        return abort(403, 'forbidden')
    (css_errors, parsed) = c.site.parse_css(stylesheet_contents)
    hooks.get_hook('subreddit.css.validate').call(request=request, form=form, op=op, stylesheet_contents=stylesheet_contents, parsed_stylesheet=parsed, css_errors=css_errors, subreddit=c.site, user=c.user)
    if css_errors:
        error_items = [CssError(x).render(style='html') for x in css_errors]
        form.set_text('.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()
        form.set_html('.errors    ul', '')
    VNotInTimeout().run(action_name='editsettings', details_text=('%s_stylesheet' % op), target=c.site)
    if ((op == 'save') and (not form.has_error())):
        wr = c.site.change_css(stylesheet_contents, parsed, reason=reason)
        form.find('.errors').hide()
        form.set_text('.status', _('saved'))
        form.set_html('.errors    ul', '')
    jquery.apply_stylesheet(parsed)
    if (op == 'preview'):
        links = SubredditStylesheet.find_preview_links(c.site)
        if links:
            jquery('#preview-table').show()
            jquery('#preview_link_normal').html(SubredditStylesheet.rendered_link(links, media='off', compress=False))
            jquery('#preview_link_media').html(SubredditStylesheet.rendered_link(links, media='on', compress=False))
            jquery('#preview_link_compressed').html(SubredditStylesheet.rendered_link(links, media='off', compress=True))
            jquery('#preview_link_stickied').html(SubredditStylesheet.rendered_link(links, media='off', compress=False, stickied=True))
        comments = SubredditStylesheet.find_preview_comments(c.site)
        if comments:
            jquery('#preview_comment').html(SubredditStylesheet.rendered_comment(comments))
            jquery('#preview_comment_gilded').html(SubredditStylesheet.rendered_comment(comments, gilded=True))
