fug
This commit is contained in:
parent
fa868f8cbd
commit
582135b954
6 changed files with 47 additions and 9 deletions
|
@ -131,7 +131,12 @@ class User(Base):
|
||||||
nwordpass = Column(Boolean)
|
nwordpass = Column(Boolean)
|
||||||
subs_created = Column(Integer, default=0)
|
subs_created = Column(Integer, default=0)
|
||||||
|
|
||||||
badges = relationship("Badge", viewonly=True)
|
badges = relationship("Badge")
|
||||||
|
awards = relationship("AwardRelationship")
|
||||||
|
mods = relationship("Mod")
|
||||||
|
comments = relationship("Comment", primaryjoin="User.id==Comment.author_id")
|
||||||
|
submissions = relationship("Submission", primaryjoin="User.id==Submission.author_id")
|
||||||
|
|
||||||
subscriptions = relationship("Subscription", viewonly=True)
|
subscriptions = relationship("Subscription", viewonly=True)
|
||||||
following = relationship("Follow", primaryjoin="Follow.user_id==User.id", viewonly=True)
|
following = relationship("Follow", primaryjoin="Follow.user_id==User.id", viewonly=True)
|
||||||
followers = relationship("Follow", primaryjoin="Follow.target_id==User.id", viewonly=True)
|
followers = relationship("Follow", primaryjoin="Follow.target_id==User.id", viewonly=True)
|
||||||
|
@ -139,7 +144,6 @@ class User(Base):
|
||||||
blocking = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
blocking = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
||||||
blocked = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
blocked = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
||||||
authorizations = relationship("ClientAuth", viewonly=True)
|
authorizations = relationship("ClientAuth", viewonly=True)
|
||||||
awards = relationship("AwardRelationship", primaryjoin="User.id==AwardRelationship.user_id", viewonly=True)
|
|
||||||
referrals = relationship("User", viewonly=True)
|
referrals = relationship("User", viewonly=True)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
|
@ -2,6 +2,7 @@ from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
from files.helpers.lazy import *
|
from files.helpers.lazy import *
|
||||||
|
import time
|
||||||
|
|
||||||
class ViewerRelationship(Base):
|
class ViewerRelationship(Base):
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,9 @@ def get_user(username, v=None, graceful=False):
|
||||||
|
|
||||||
def get_account(id, v=None):
|
def get_account(id, v=None):
|
||||||
|
|
||||||
|
try: id = int(id)
|
||||||
|
except: abort(404)
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(id = id).one_or_none()
|
user = g.db.query(User).filter_by(id = id).one_or_none()
|
||||||
|
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
|
|
|
@ -22,6 +22,42 @@ GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN", "").strip()
|
||||||
|
|
||||||
month = datetime.now().strftime('%B')
|
month = datetime.now().strftime('%B')
|
||||||
|
|
||||||
|
@app.get('/admin/merge/<id1>/<id2>')
|
||||||
|
@admin_level_required(3)
|
||||||
|
def merge(v, id1, id2):
|
||||||
|
if v.id != 1: abort(403)
|
||||||
|
user1 = get_user(id1)
|
||||||
|
user2 = get_user(id2)
|
||||||
|
|
||||||
|
for award in user2.awards:
|
||||||
|
award.user_id = user1.id
|
||||||
|
g.db.add(award)
|
||||||
|
for badge in user2.badges:
|
||||||
|
if not user1.has_badge(badge.badge_id):
|
||||||
|
badge.user_id = user1.id
|
||||||
|
g.db.add(badge)
|
||||||
|
for mod in user2.mods:
|
||||||
|
mod.user_id = user1.id
|
||||||
|
g.db.add(mod)
|
||||||
|
for comment in user2.comments:
|
||||||
|
comment.author_id = user1.id
|
||||||
|
g.db.add(comment)
|
||||||
|
for submission in user2.submissions:
|
||||||
|
submission.author_id = user1.id
|
||||||
|
g.db.add(submission)
|
||||||
|
|
||||||
|
for kind in ('comment_count', 'post_count', 'winnings', 'received_award_count', 'coins_spent', 'lootboxes_bought', 'coins', 'truecoins', 'procoins', 'subs_created'):
|
||||||
|
setattr(user1, kind, getattr(user2, kind))
|
||||||
|
setattr(user2, kind, 0)
|
||||||
|
|
||||||
|
g.db.add(user1)
|
||||||
|
g.db.add(user2)
|
||||||
|
g.db.commit()
|
||||||
|
return f"Success! moved @{user2.username} to @{user1.username}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if SITE_NAME == 'PCM':
|
if SITE_NAME == 'PCM':
|
||||||
@app.get('/admin/sidebar')
|
@app.get('/admin/sidebar')
|
||||||
@admin_level_required(3)
|
@admin_level_required(3)
|
||||||
|
|
|
@ -1369,6 +1369,7 @@ def submit_post(v, sub=None):
|
||||||
|
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
|
|
||||||
|
snappy = g.db.query(User).filter_by(id = SNAPPY_ID).one_or_none()
|
||||||
snappy.comment_count += 1
|
snappy.comment_count += 1
|
||||||
snappy.coins += 1
|
snappy.coins += 1
|
||||||
g.db.add(snappy)
|
g.db.add(snappy)
|
||||||
|
|
|
@ -651,8 +651,6 @@ def api_is_available(name, v):
|
||||||
@app.get("/id/<id>")
|
@app.get("/id/<id>")
|
||||||
@auth_required
|
@auth_required
|
||||||
def user_id(id, v):
|
def user_id(id, v):
|
||||||
try: id = int(id)
|
|
||||||
except: abort(404)
|
|
||||||
user = get_account(id)
|
user = get_account(id)
|
||||||
return redirect(user.url)
|
return redirect(user.url)
|
||||||
|
|
||||||
|
@ -886,9 +884,6 @@ def u_username_info(username, v=None):
|
||||||
@auth_required
|
@auth_required
|
||||||
def u_user_id_info(id, v=None):
|
def u_user_id_info(id, v=None):
|
||||||
|
|
||||||
try: id = int(id)
|
|
||||||
except: abort(404)
|
|
||||||
|
|
||||||
user=get_account(id, v=v)
|
user=get_account(id, v=v)
|
||||||
|
|
||||||
if hasattr(user, 'is_blocking') and user.is_blocking:
|
if hasattr(user, 'is_blocking') and user.is_blocking:
|
||||||
|
@ -976,8 +971,6 @@ def remove_follow(username, v):
|
||||||
def user_profile_uid(v, id):
|
def user_profile_uid(v, id):
|
||||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||||
|
|
||||||
try: id = int(id)
|
|
||||||
except: abort(404)
|
|
||||||
x=get_account(id)
|
x=get_account(id)
|
||||||
return redirect(x.profile_url)
|
return redirect(x.profile_url)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue