forked from rDrama/rDrama
fsd
parent
70813c686a
commit
38e853250e
|
@ -34,41 +34,43 @@ def check_for_alts(current_id):
|
||||||
if past_id == MOM_ID or current_id == MOM_ID: break
|
if past_id == MOM_ID or current_id == MOM_ID: break
|
||||||
if past_id == current_id: continue
|
if past_id == current_id: continue
|
||||||
|
|
||||||
check1 = g.db.query(Alt).filter_by(
|
li = [past_id, current_id]
|
||||||
user1=current_id, user2=past_id).one_or_none()
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
|
||||||
check2 = g.db.query(Alt).filter_by(
|
|
||||||
user1=past_id, user2=current_id).one_or_none()
|
|
||||||
|
|
||||||
if not check1 and not check2:
|
if not existing:
|
||||||
|
|
||||||
try:
|
|
||||||
new_alt = Alt(user1=past_id, user2=current_id)
|
new_alt = Alt(user1=past_id, user2=current_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
except: pass
|
|
||||||
|
|
||||||
alts = g.db.query(Alt)
|
otheralts = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).all()
|
||||||
otheralts = alts.filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all()
|
|
||||||
for a in otheralts:
|
for a in otheralts:
|
||||||
existing = alts.filter_by(user1=a.user1, user2=past_id).one_or_none()
|
if a.user1 != past_id:
|
||||||
|
li = [a.user1, past_id]
|
||||||
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
|
||||||
if not existing:
|
if not existing:
|
||||||
new_alt = Alt(user1=a.user1, user2=past_id)
|
new_alt = Alt(user1=a.user1, user2=past_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
existing = alts.filter_by(user1=a.user1, user2=current_id).one_or_none()
|
if a.user1 != current_id:
|
||||||
|
li = [a.user1, current_id]
|
||||||
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
|
||||||
if not existing:
|
if not existing:
|
||||||
new_alt = Alt(user1=a.user1, user2=current_id)
|
new_alt = Alt(user1=a.user1, user2=current_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
existing = alts.filter_by(user1=a.user2, user2=past_id).one_or_none()
|
if a.user2 != past_id:
|
||||||
|
li = [a.user2, past_id]
|
||||||
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
|
||||||
if not existing:
|
if not existing:
|
||||||
new_alt = Alt(user1=a.user2, user2=past_id)
|
new_alt = Alt(user1=a.user2, user2=past_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
existing = alts.filter_by(user1=a.user2, user2=current_id).one_or_none()
|
if a.user2 != current_id:
|
||||||
|
li = [a.user2, current_id]
|
||||||
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
|
||||||
if not existing:
|
if not existing:
|
||||||
new_alt = Alt(user1=a.user2, user2=current_id)
|
new_alt = Alt(user1=a.user2, user2=current_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
|
|
|
@ -1010,7 +1010,6 @@ def saved_comments(v, username):
|
||||||
@app.post("/fp/<fp>")
|
@app.post("/fp/<fp>")
|
||||||
@auth_required
|
@auth_required
|
||||||
def fp(v, fp):
|
def fp(v, fp):
|
||||||
if v.username != fp:
|
|
||||||
v.fp = fp
|
v.fp = fp
|
||||||
users = g.db.query(User).filter(User.fp == fp, User.id != v.id).all()
|
users = g.db.query(User).filter(User.fp == fp, User.id != v.id).all()
|
||||||
if users: print(f'{v.username}: fp {v.fp}')
|
if users: print(f'{v.username}: fp {v.fp}')
|
||||||
|
@ -1026,7 +1025,7 @@ def fp(v, fp):
|
||||||
new_alt = Alt(user1=v.id, user2=u.id)
|
new_alt = Alt(user1=v.id, user2=u.id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
print('\n\n' + v.username + ' + ' + u.username + '\n\n')
|
print(v.username + ' + ' + u.username)
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return '', 204
|
return '', 204
|
Loading…
Reference in New Issue