Skip to content
This repository has been archived by the owner on Jun 24, 2023. It is now read-only.

Commit

Permalink
make new link/post sendreplies choice sticky
Browse files Browse the repository at this point in the history
  • Loading branch information
libertysoft3 committed Oct 27, 2018
1 parent 1eeb72a commit a911826
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions r2/r2/controllers/api.py
Expand Up @@ -569,6 +569,12 @@ def POST_submit(self, form, jquery, url, selftext, kind, title,
VRatelimit.ratelimit(rate_user=True, rate_ip = True,
prefix = "rate_submit_")

# CUSTOM: sendreplies is sticky, sets a preference
if c.user.pref_sendreplies is not sendreplies:
prefs = {"pref_sendreplies": sendreplies}
set_prefs(c.user, prefs)
c.user._commit()

queries.new_link(l)
l.update_search_index()
g.events.submit_event(l, request=request, context=c)
Expand Down
11 changes: 6 additions & 5 deletions r2/r2/models/account.py
Expand Up @@ -161,16 +161,17 @@ class Account(Thing):
in_timeout=False,
has_used_mobile_app=False,
disable_karma=False,
# CUSTOM

# CUSTOM
pref_chat_enabled=True,
pref_chat_sidebar_size=g.live_config['chat_default_sidebar_size'],
pref_chat_user=g.live_config['chat_default_username'],
pref_chat_client_user=g.live_config['chat_default_username'],
pref_chat_client_password='',
pref_subscriptions_unsubscribe='subs_do_nothing',
pref_site_theme=g.live_config['site_theme_default'],
pref_lightswitch=False if g.live_config['site_theme_lightswitch_default'] == 'off' else True,
pref_subscriptions_unsubscribe='subs_do_nothing',
pref_site_theme=g.live_config['site_theme_default'],
pref_lightswitch=False if g.live_config['site_theme_lightswitch_default'] == 'off' else True,
pref_sendreplies=True,
)
_preference_attrs = tuple(k for k in _defaults.keys()
if k.startswith("pref_"))
Expand Down
2 changes: 1 addition & 1 deletion r2/r2/templates/newlink.html
Expand Up @@ -118,7 +118,7 @@ <h1>${_wsf('submitting to %(sr)s', sr=unsafe('/' + g.brander_community_abbr + '/

<div class="spacer">
<%utils:round_field title="${_('options')}">
<input class="nomargin" type="checkbox" checked="checked" name="sendreplies" id="sendreplies" data-send-checked="true"/>
<input class="nomargin" type="checkbox" ${'checked="checked"' if c.user.pref_sendreplies else ''} name="sendreplies" id="sendreplies" data-send-checked="true"/>
<label for="sendreplies">
${_("send replies to my inbox")}
</label>
Expand Down

0 comments on commit a911826

Please sign in to comment.