forked from MarseyWorld/MarseyWorld
Add Y'all Seein' Eye award v2 for offsitementions.
Reusing the assets and design for the ill-fated YSE in a0f441a67d
.
This time, the award provides access to our offsite mentions (reddit
notifs).
master
parent
933f2a9a40
commit
8709ca816d
|
@ -90,6 +90,7 @@ class User(Base):
|
||||||
unmutable = Column(Boolean)
|
unmutable = Column(Boolean)
|
||||||
eye = Column(Boolean)
|
eye = Column(Boolean)
|
||||||
alt = Column(Boolean)
|
alt = Column(Boolean)
|
||||||
|
offsitementions = Column(Boolean, default=False, nullable=False)
|
||||||
frontsize = Column(Integer, default=25)
|
frontsize = Column(Integer, default=25)
|
||||||
controversial = Column(Boolean, default=False)
|
controversial = Column(Boolean, default=False)
|
||||||
bio = deferred(Column(String))
|
bio = deferred(Column(String))
|
||||||
|
@ -229,7 +230,11 @@ class User(Base):
|
||||||
if self.has_badge(badge): discount -= discounts[badge]
|
if self.has_badge(badge): discount -= discounts[badge]
|
||||||
|
|
||||||
return discount
|
return discount
|
||||||
|
|
||||||
|
@property
|
||||||
|
@lazy
|
||||||
|
def can_view_offsitementions(self):
|
||||||
|
return self.offsitementions or self.admin_level >= REDDIT_NOTIFS_JL_MIN
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
|
|
|
@ -5,12 +5,12 @@ from files.classes.badges import Badge, BadgeDef
|
||||||
# TODO: More sanity checks on passed parameters.
|
# TODO: More sanity checks on passed parameters.
|
||||||
# TODO: Add `replace=False` parameter which, when set true, removes any
|
# TODO: Add `replace=False` parameter which, when set true, removes any
|
||||||
# existing badge with identical id & user and replaces with new one.
|
# existing badge with identical id & user and replaces with new one.
|
||||||
def badge_grant(user_id, badge_id, desc='', url=''):
|
def badge_grant(user_id, badge_id, desc='', url='', commit=True):
|
||||||
user = g.db.query(User).filter(User.id == int(user_id)).one_or_none()
|
user = g.db.query(User).filter(User.id == int(user_id)).one_or_none()
|
||||||
if not user:
|
if not user:
|
||||||
return False
|
return None
|
||||||
elif user.has_badge(badge_id):
|
elif user.has_badge(badge_id):
|
||||||
return True
|
return None
|
||||||
|
|
||||||
badge = Badge(
|
badge = Badge(
|
||||||
badge_id=int(badge_id),
|
badge_id=int(badge_id),
|
||||||
|
@ -20,5 +20,8 @@ def badge_grant(user_id, badge_id, desc='', url=''):
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(badge)
|
g.db.add(badge)
|
||||||
g.db.commit()
|
if commit:
|
||||||
return True
|
g.db.commit()
|
||||||
|
else:
|
||||||
|
g.db.flush()
|
||||||
|
return badge
|
||||||
|
|
|
@ -662,6 +662,14 @@ AWARDS = {
|
||||||
"color": "text-silver",
|
"color": "text-silver",
|
||||||
"price": 10000
|
"price": 10000
|
||||||
},
|
},
|
||||||
|
"offsitementions": {
|
||||||
|
"kind": "offsitementions",
|
||||||
|
"title": "Y'all Seein' Eye",
|
||||||
|
"description": "Gives the recipient access to notifications when people off-site talk about us.",
|
||||||
|
"icon": "fas fa-eyes",
|
||||||
|
"color": "text-orange",
|
||||||
|
"price": 10000,
|
||||||
|
},
|
||||||
"unblockable": {
|
"unblockable": {
|
||||||
"kind": "unblockable",
|
"kind": "unblockable",
|
||||||
"title": "Unblockable",
|
"title": "Unblockable",
|
||||||
|
@ -803,6 +811,7 @@ else: patron = 'Patron'
|
||||||
|
|
||||||
REDDIT_NOTIFS_SITE = []
|
REDDIT_NOTIFS_SITE = []
|
||||||
REDDIT_NOTIFS_USERS = {}
|
REDDIT_NOTIFS_USERS = {}
|
||||||
|
REDDIT_NOTIFS_JL_MIN = 1
|
||||||
|
|
||||||
if SITE_NAME == 'rDrama':
|
if SITE_NAME == 'rDrama':
|
||||||
REDDIT_NOTIFS_SITE = ['rdrama', 'marsey',]
|
REDDIT_NOTIFS_SITE = ['rdrama', 'marsey',]
|
||||||
|
@ -816,6 +825,7 @@ if SITE_NAME == 'rDrama':
|
||||||
}
|
}
|
||||||
elif SITE_NAME == 'PCM':
|
elif SITE_NAME == 'PCM':
|
||||||
REDDIT_NOTIFS_SITE = ['pcmemes.net',]
|
REDDIT_NOTIFS_SITE = ['pcmemes.net',]
|
||||||
|
REDDIT_NOTIFS_JL_MIN = 3
|
||||||
|
|
||||||
discounts = {
|
discounts = {
|
||||||
# Big Spender badges, 2pp additive discount each
|
# Big Spender badges, 2pp additive discount each
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from flask import g
|
from flask import g
|
||||||
import itertools
|
import itertools
|
||||||
import requests
|
import requests
|
||||||
|
from sqlalchemy import _or
|
||||||
import files.helpers.const as const
|
import files.helpers.const as const
|
||||||
from files.classes.user import User
|
from files.classes.user import User
|
||||||
from files.classes.comment import Comment
|
from files.classes.comment import Comment
|
||||||
|
@ -13,9 +14,9 @@ from files.classes.notifications import Notification
|
||||||
|
|
||||||
def offsite_mentions_task():
|
def offsite_mentions_task():
|
||||||
if const.REDDIT_NOTIFS_SITE:
|
if const.REDDIT_NOTIFS_SITE:
|
||||||
# Site-specific logic: send to JL1+, except on PCM JL3+
|
row_send_to = g.db.query(User.id)
|
||||||
jl_min = 3 if const.SITE_NAME == 'PCM' else 1
|
.filter(_or(User.admin_level >= const.REDDIT_NOTIFS_JL_MIN,
|
||||||
row_send_to = g.db.query(User.id).filter(User.admin_level >= jl_min).all()
|
User.offsitementions == True)).all()
|
||||||
send_to = [x[0] for x in row_send_to]
|
send_to = [x[0] for x in row_send_to]
|
||||||
|
|
||||||
site_mentions = get_mentions(const.REDDIT_NOTIFS_SITE)
|
site_mentions = get_mentions(const.REDDIT_NOTIFS_SITE)
|
||||||
|
|
|
@ -4,6 +4,7 @@ from files.helpers.alerts import *
|
||||||
from files.helpers.get import *
|
from files.helpers.get import *
|
||||||
from files.helpers.const import *
|
from files.helpers.const import *
|
||||||
from files.helpers.discord import *
|
from files.helpers.discord import *
|
||||||
|
from files.helpers.actions import badge_grant
|
||||||
from files.classes.award import *
|
from files.classes.award import *
|
||||||
from .front import frontlist
|
from .front import frontlist
|
||||||
from flask import g, request
|
from flask import g, request
|
||||||
|
@ -301,6 +302,10 @@ def award_thing(v, thing_type, id):
|
||||||
g.db.add(new_badge)
|
g.db.add(new_badge)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}")
|
send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}")
|
||||||
|
elif kind == "offsitementions":
|
||||||
|
author.offsitementions = True
|
||||||
|
new_badge = badge_grant(user_id=author.id, badge_id=140, commit=False)
|
||||||
|
send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}")
|
||||||
elif kind == "alt":
|
elif kind == "alt":
|
||||||
author.alt = True
|
author.alt = True
|
||||||
if not author.has_badge(84):
|
if not author.has_badge(84):
|
||||||
|
|
|
@ -30,14 +30,14 @@
|
||||||
Messages
|
Messages
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% if v.admin_level > 1 %}
|
{% if v.admin_level >= 2 %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link py-3{% if '/notifications?modmail=true' in request.full_path %} active{% endif %}" href="/notifications?modmail=true">
|
<a class="nav-link py-3{% if '/notifications?modmail=true' in request.full_path %} active{% endif %}" href="/notifications?modmail=true">
|
||||||
Modmail
|
Modmail
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if v.admin_level %}
|
{% if v.can_view_offsitementions %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link py-3{% if '/notifications?reddit=true' in request.full_path %} active{% endif %}" href="/notifications?reddit=true">
|
<a class="nav-link py-3{% if '/notifications?reddit=true' in request.full_path %} active{% endif %}" href="/notifications?reddit=true">
|
||||||
Reddit {% if v.reddit_notifications_count %}<span class="font-weight-bold" style="color:#805ad5">({{v.reddit_notifications_count}})</span>{% endif %}
|
Reddit {% if v.reddit_notifications_count %}<span class="font-weight-bold" style="color:#805ad5">({{v.reddit_notifications_count}})</span>{% endif %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{%-
|
{%-
|
||||||
set CACHE_VER = {
|
set CACHE_VER = {
|
||||||
'css/main.css': 297,
|
'css/main.css': 298,
|
||||||
|
|
||||||
'css/4chan.css': 59,
|
'css/4chan.css': 59,
|
||||||
'css/classic.css': 59,
|
'css/classic.css': 59,
|
||||||
|
|
Loading…
Reference in New Issue