fsd
This commit is contained in:
parent
ad2323c858
commit
0c6249f6a1
2 changed files with 53 additions and 52 deletions
|
@ -34,45 +34,47 @@ 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:
|
||||||
|
new_alt = Alt(user1=past_id, user2=current_id)
|
||||||
try:
|
g.db.add(new_alt)
|
||||||
new_alt = Alt(user1=past_id, user2=current_id)
|
g.db.flush()
|
||||||
g.db.add(new_alt)
|
|
||||||
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:
|
||||||
if not existing:
|
li = [a.user1, past_id]
|
||||||
new_alt = Alt(user1=a.user1, user2=past_id)
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
|
||||||
g.db.add(new_alt)
|
if not existing:
|
||||||
g.db.flush()
|
new_alt = Alt(user1=a.user1, user2=past_id)
|
||||||
|
g.db.add(new_alt)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
existing = alts.filter_by(user1=a.user1, user2=current_id).one_or_none()
|
if a.user1 != current_id:
|
||||||
if not existing:
|
li = [a.user1, current_id]
|
||||||
new_alt = Alt(user1=a.user1, user2=current_id)
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
|
||||||
g.db.add(new_alt)
|
if not existing:
|
||||||
g.db.flush()
|
new_alt = Alt(user1=a.user1, user2=current_id)
|
||||||
|
g.db.add(new_alt)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
existing = alts.filter_by(user1=a.user2, user2=past_id).one_or_none()
|
if a.user2 != past_id:
|
||||||
if not existing:
|
li = [a.user2, past_id]
|
||||||
new_alt = Alt(user1=a.user2, user2=past_id)
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
|
||||||
g.db.add(new_alt)
|
if not existing:
|
||||||
g.db.flush()
|
new_alt = Alt(user1=a.user2, user2=past_id)
|
||||||
|
g.db.add(new_alt)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
existing = alts.filter_by(user1=a.user2, user2=current_id).one_or_none()
|
if a.user2 != current_id:
|
||||||
if not existing:
|
li = [a.user2, current_id]
|
||||||
new_alt = Alt(user1=a.user2, user2=current_id)
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).one_or_none()
|
||||||
g.db.add(new_alt)
|
if not existing:
|
||||||
g.db.flush()
|
new_alt = Alt(user1=a.user2, user2=current_id)
|
||||||
|
g.db.add(new_alt)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
|
|
||||||
@app.post("/login")
|
@app.post("/login")
|
||||||
|
|
|
@ -1010,23 +1010,22 @@ 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}')
|
if v.email and v.is_activated:
|
||||||
if v.email and v.is_activated:
|
alts = g.db.query(User).filter(User.email == v.email, User.is_activated, User.id != v.id).all()
|
||||||
alts = g.db.query(User).filter(User.email == v.email, User.is_activated, User.id != v.id).all()
|
if alts:
|
||||||
if alts:
|
print(f'{v.username}: email {v.email}')
|
||||||
print(f'{v.username}: email {v.email}')
|
users += alts
|
||||||
users += alts
|
for u in users:
|
||||||
for u in users:
|
li = [v.id, u.id]
|
||||||
li = [v.id, u.id]
|
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).first()
|
||||||
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).first()
|
if existing: continue
|
||||||
if existing: continue
|
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(v.username + ' + ' + u.username)
|
||||||
print('\n\n' + v.username + ' + ' + u.username + '\n\n')
|
g.db.add(v)
|
||||||
g.db.add(v)
|
g.db.commit()
|
||||||
g.db.commit()
|
|
||||||
return '', 204
|
return '', 204
|
Loading…
Add table
Add a link
Reference in a new issue