master
Aevann1 2022-01-29 15:43:29 +02:00
parent b95b10625d
commit e79fb81819
6 changed files with 11 additions and 11 deletions

View File

@ -462,5 +462,4 @@ class SaveRelationship(Base):
id=Column(Integer, primary_key=True)
user_id=Column(Integer)
submission_id=Column(Integer)
comment_id=Column(Integer)
type=Column(Integer)
comment_id=Column(Integer)

View File

@ -551,12 +551,12 @@ class User(Base):
@property
@lazy
def saved_count(self):
return g.db.query(SaveRelationship.submission_id).filter(SaveRelationship.user_id == self.id).count()
return g.db.query(SaveRelationship.submission_id).filter(SaveRelationship.user_id == self.id, SaveRelationship.submission_id != None).count()
@property
@lazy
def saved_comment_count(self):
return g.db.query(SaveRelationship.comment_id).filter(SaveRelationship.user_id == self.id).count()
return g.db.query(SaveRelationship.comment_id).filter(SaveRelationship.user_id == self.id, SaveRelationship.comment_id != None).count()
@lazy
def saved_idlist(self, page=1):

View File

@ -876,10 +876,10 @@ def save_comment(cid, v):
comment=get_comment(cid)
save=g.db.query(SaveRelationship).filter_by(user_id=v.id, comment_id=comment.id, type=2).one_or_none()
save=g.db.query(SaveRelationship).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
if not save:
new_save=SaveRelationship(user_id=v.id, comment_id=comment.id, type=2)
new_save=SaveRelationship(user_id=v.id, comment_id=comment.id)
g.db.add(new_save)
try: g.db.commit()
@ -894,7 +894,7 @@ def unsave_comment(cid, v):
comment=get_comment(cid)
save=g.db.query(SaveRelationship).filter_by(user_id=v.id, comment_id=comment.id, type=2).one_or_none()
save=g.db.query(SaveRelationship).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
if save:
g.db.delete(save)

View File

@ -1254,10 +1254,10 @@ def save_post(pid, v):
post=get_post(pid)
save = g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=post.id, type=1).one_or_none()
save = g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=post.id).one_or_none()
if not save:
new_save=SaveRelationship(user_id=v.id, submission_id=post.id, type=1)
new_save=SaveRelationship(user_id=v.id, submission_id=post.id)
g.db.add(new_save)
g.db.commit()
@ -1270,7 +1270,7 @@ def unsave_post(pid, v):
post=get_post(pid)
save = g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=post.id, type=1).one_or_none()
save = g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=post.id).one_or_none()
if save:
g.db.delete(save)

View File

@ -264,8 +264,10 @@
{% elif blackjack_status == 'lost' %}
<strong>Lost {{wager}} Coins.</strong>
{% elif blackjack_status == 'won' %}
{% set wager = wager|int*2 %}
<strong>Won {{wager}} Coins.</strong>
{% elif blackjack_status == 'blackjack' %}
{% set wager = wager|int*5/2 %}
<strong>Blackjack! Won <span id="blackjack-result-{{c.id}}">{{wager}}</span> Coins.</strong>
<script>
var blackjackResult = document.getElementById('blackjack-result-{{c.id}}');

View File

@ -566,7 +566,6 @@ CREATE TABLE public.save_relationship (
id integer NOT NULL,
submission_id integer,
user_id integer,
type integer,
comment_id integer
);