forked from MarseyWorld/MarseyWorld
fdsfds
parent
64c572ab3b
commit
8532719783
|
@ -281,9 +281,15 @@ class User(Base):
|
|||
if not self.is_suspended: return None
|
||||
return g.db.query(User).filter_by(id=self.is_banned).first()
|
||||
|
||||
@lazy
|
||||
def has_badge(self, badge_id):
|
||||
return g.db.query(Badge).filter_by(user_id=self.id, badge_id=badge_id).first()
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def grinch(self):
|
||||
return self.has_badge(91)
|
||||
|
||||
def hash_password(self, password):
|
||||
return generate_password_hash(
|
||||
password, method='pbkdf2:sha512', salt_length=8)
|
||||
|
@ -418,6 +424,7 @@ class User(Base):
|
|||
@property
|
||||
@lazy
|
||||
def profile_url(self):
|
||||
if self.grinch: return f"https://{site}/assets/images/grinch.webp?v=1"
|
||||
if self.agendaposter: return f"https://{site}/assets/images/defaultpictures/agendaposter/{random.randint(1, 50)}.webp?v=1"
|
||||
if self.profileurl: return self.profileurl
|
||||
if "rama" in site: return f"https://{site}/assets/images/defaultpictures/{random.randint(1, 150)}.webp?v=1"
|
||||
|
|
|
@ -456,6 +456,14 @@ AWARDS = {
|
|||
"color": "",
|
||||
"price": 1000
|
||||
},
|
||||
"grinch": {
|
||||
"kind": "grinch",
|
||||
"title": "Grinch",
|
||||
"description": "???",
|
||||
"icon": "fas fa-angry",
|
||||
"color": "text-green-500",
|
||||
"price": 1000
|
||||
},
|
||||
"haunt": {
|
||||
"kind": "haunt",
|
||||
"title": "Haunt",
|
||||
|
@ -716,6 +724,14 @@ AWARDS2 = {
|
|||
"color": "",
|
||||
"price": 1000
|
||||
},
|
||||
"grinch": {
|
||||
"kind": "grinch",
|
||||
"title": "Grinch",
|
||||
"description": "???",
|
||||
"icon": "fas fa-angry",
|
||||
"color": "text-green-500",
|
||||
"price": 1000
|
||||
},
|
||||
"shit": {
|
||||
"kind": "shit",
|
||||
"title": "Shit",
|
||||
|
|
|
@ -883,7 +883,7 @@ def ban_post(post_id, v):
|
|||
|
||||
cache.delete_memoized(frontlist)
|
||||
|
||||
v.coins += 1
|
||||
v.coins += 2
|
||||
g.db.add(v)
|
||||
|
||||
g.db.commit()
|
||||
|
@ -917,7 +917,7 @@ def unban_post(post_id, v):
|
|||
|
||||
cache.delete_memoized(frontlist)
|
||||
|
||||
v.coins -= 1
|
||||
v.coins -= 2
|
||||
g.db.add(v)
|
||||
|
||||
g.db.commit()
|
||||
|
|
|
@ -102,6 +102,15 @@ def shop(v):
|
|||
"owned": 0,
|
||||
"price": 1000
|
||||
},
|
||||
"grinch": {
|
||||
"kind": "grinch",
|
||||
"title": "Grinch",
|
||||
"description": "???",
|
||||
"icon": "fas fa-angry",
|
||||
"color": "text-green-500",
|
||||
"owned": 0,
|
||||
"price": 1000
|
||||
},
|
||||
"shit": {
|
||||
"kind": "shit",
|
||||
"title": "Shit",
|
||||
|
@ -348,6 +357,14 @@ def buy(v, award):
|
|||
"color": "",
|
||||
"price": 1000
|
||||
},
|
||||
"grinch": {
|
||||
"kind": "grinch",
|
||||
"title": "Grinch",
|
||||
"description": "???",
|
||||
"icon": "fas fa-angry",
|
||||
"color": "text-green-500",
|
||||
"price": 1000
|
||||
},
|
||||
"shit": {
|
||||
"kind": "shit",
|
||||
"title": "Shit",
|
||||
|
@ -718,6 +735,11 @@ def award_post(pid, v):
|
|||
if not author.has_badge(90):
|
||||
new_badge = Badge(badge_id=90, user_id=author.id)
|
||||
g.db.add(new_badge)
|
||||
elif kind == "grinch":
|
||||
send_notification(CARP_ID, f"@{v.username} used {kind} award!")
|
||||
if not author.has_badge(91):
|
||||
new_badge = Badge(badge_id=91, user_id=author.id)
|
||||
g.db.add(new_badge)
|
||||
|
||||
if post.author.received_award_count: post.author.received_award_count += 1
|
||||
else: post.author.received_award_count = 1
|
||||
|
@ -880,6 +902,11 @@ def award_comment(cid, v):
|
|||
if not author.has_badge(90):
|
||||
new_badge = Badge(badge_id=90, user_id=author.id)
|
||||
g.db.add(new_badge)
|
||||
elif kind == "grinch":
|
||||
send_notification(CARP_ID, f"@{v.username} used {kind} award!")
|
||||
if not author.has_badge(91):
|
||||
new_badge = Badge(badge_id=91, user_id=author.id)
|
||||
g.db.add(new_badge)
|
||||
|
||||
if c.author.received_award_count: c.author.received_award_count += 1
|
||||
else: c.author.received_award_count = 1
|
||||
|
|
|
@ -407,7 +407,7 @@ def api_comment(v):
|
|||
if v.id == PIZZA_SHILL_ID:
|
||||
cratvote = CommentVote(user_id=TAX_RECEIVER_ID, comment_id=c.id, vote_type=1)
|
||||
g.db.add(cratvote)
|
||||
v.coins += 1
|
||||
v.coins += 2
|
||||
v.truecoins += 1
|
||||
g.db.add(v)
|
||||
c.upvotes += 1
|
||||
|
@ -433,7 +433,7 @@ def api_comment(v):
|
|||
|
||||
longpostbot = g.db.query(User).filter_by(id = LONGPOSTBOT_ID).first()
|
||||
longpostbot.comment_count += 1
|
||||
longpostbot.coins += 1
|
||||
longpostbot.coins += 2
|
||||
g.db.add(longpostbot)
|
||||
|
||||
g.db.flush()
|
||||
|
|
|
@ -1178,7 +1178,7 @@ def submit_post(v):
|
|||
|
||||
snappy = g.db.query(User).filter_by(id = SNAPPY_ID).first()
|
||||
snappy.comment_count += 1
|
||||
snappy.coins += 1
|
||||
snappy.coins += 2
|
||||
g.db.add(snappy)
|
||||
|
||||
g.db.flush()
|
||||
|
|
|
@ -69,7 +69,7 @@ def admin_vote_info_get(v):
|
|||
@validate_formkey
|
||||
def api_vote_post(post_id, new, v):
|
||||
|
||||
if v.is_banned and not v.unban_utc: return {"error": "forbidden."}, 403
|
||||
if v.is_banned and not v.unban_utc or new == "-1": return {"error": "forbidden."}, 403
|
||||
|
||||
if new not in ["-1", "0", "1"]: abort(400)
|
||||
|
||||
|
@ -85,13 +85,13 @@ def api_vote_post(post_id, new, v):
|
|||
|
||||
if existing:
|
||||
if existing.vote_type == 0 and new != 0:
|
||||
post.author.coins += 1
|
||||
post.author.coins += 2
|
||||
post.author.truecoins += 1
|
||||
g.db.add(post.author)
|
||||
existing.vote_type = new
|
||||
g.db.add(existing)
|
||||
elif existing.vote_type != 0 and new == 0:
|
||||
post.author.coins -= 1
|
||||
post.author.coins -= 2
|
||||
post.author.truecoins -= 1
|
||||
g.db.add(post.author)
|
||||
g.db.delete(existing)
|
||||
|
@ -99,7 +99,7 @@ def api_vote_post(post_id, new, v):
|
|||
existing.vote_type = new
|
||||
g.db.add(existing)
|
||||
elif new != 0:
|
||||
post.author.coins += 1
|
||||
post.author.coins += 2
|
||||
post.author.truecoins += 1
|
||||
g.db.add(post.author)
|
||||
real = (bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor) and not v.agendaposter and not v.shadowbanned
|
||||
|
@ -132,7 +132,7 @@ def api_vote_post(post_id, new, v):
|
|||
@validate_formkey
|
||||
def api_vote_comment(comment_id, new, v):
|
||||
|
||||
if v.is_banned and not v.unban_utc: return {"error": "forbidden."}, 403
|
||||
if v.is_banned and not v.unban_utc or new == "-1": return {"error": "forbidden."}, 403
|
||||
|
||||
if new not in ["-1", "0", "1"]: abort(400)
|
||||
|
||||
|
@ -153,13 +153,13 @@ def api_vote_comment(comment_id, new, v):
|
|||
|
||||
if existing:
|
||||
if existing.vote_type == 0 and new != 0:
|
||||
comment.author.coins += 1
|
||||
comment.author.coins += 2
|
||||
comment.author.truecoins += 1
|
||||
g.db.add(comment.author)
|
||||
existing.vote_type = new
|
||||
g.db.add(existing)
|
||||
elif existing.vote_type != 0 and new == 0:
|
||||
comment.author.coins -= 1
|
||||
comment.author.coins -= 2
|
||||
comment.author.truecoins -= 1
|
||||
g.db.add(comment.author)
|
||||
g.db.delete(existing)
|
||||
|
@ -167,7 +167,7 @@ def api_vote_comment(comment_id, new, v):
|
|||
existing.vote_type = new
|
||||
g.db.add(existing)
|
||||
elif new != 0:
|
||||
comment.author.coins += 1
|
||||
comment.author.coins += 2
|
||||
comment.author.truecoins += 1
|
||||
g.db.add(comment.author)
|
||||
real = (bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor) and not v.agendaposter and not v.shadowbanned
|
||||
|
|
Loading…
Reference in New Issue