forked from MarseyWorld/MarseyWorld
make checking if a post/comment is saved less retarded
parent
19c82b7ea1
commit
2b1e7f6570
|
@ -562,3 +562,8 @@ class Comment(Base):
|
|||
|
||||
body += '</span>'
|
||||
return body
|
||||
|
||||
|
||||
@lazy
|
||||
def is_saved(self, v):
|
||||
return g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=self.id).first()
|
|
@ -501,4 +501,9 @@ class Submission(Base):
|
|||
return False
|
||||
|
||||
@lazy
|
||||
def active_flags(self, v): return len(self.flags(v))
|
||||
def active_flags(self, v):
|
||||
return len(self.flags(v))
|
||||
|
||||
@lazy
|
||||
def is_saved(self, v):
|
||||
return g.db.query(CommentSaveRelationship).filter_by(user_id=v.id, comment_id=self.id).first()
|
|
@ -20,8 +20,8 @@
|
|||
{% endif %}
|
||||
|
||||
{% if v %}
|
||||
<a id="save-{{p.id}}" class="{% if p.id in v.saved_idlist() %}d-none{% endif %} list-inline-item" role="button" onclick="post_toast(this,'/save_post/{{p.id}}','save-{{p.id}}','unsave-{{p.id}}','d-none')"><i class="fas fa-save"></i>Save</a>
|
||||
<a id="unsave-{{p.id}}" class="{% if not p.id in v.saved_idlist() %}d-none{% endif %} list-inline-item" role="button" onclick="post_toast(this,'/unsave_post/{{p.id}}','save-{{p.id}}','unsave-{{p.id}}','d-none')"><i class="fas fa-save"></i>Unsave</a>
|
||||
<a id="save-{{p.id}}" class="{% if p.is_saved(v) %}d-none{% endif %} list-inline-item" role="button" onclick="post_toast(this,'/save_post/{{p.id}}','save-{{p.id}}','unsave-{{p.id}}','d-none')"><i class="fas fa-save"></i>Save</a>
|
||||
<a id="unsave-{{p.id}}" class="{% if not p.is_saved(v) %}d-none{% endif %} list-inline-item" role="button" onclick="post_toast(this,'/unsave_post/{{p.id}}','save-{{p.id}}','unsave-{{p.id}}','d-none')"><i class="fas fa-save"></i>Unsave</a>
|
||||
|
||||
<a class="list-inline-item" role="button" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#reportPostModal" onclick="report_postModal('{{p.id}}')"><i class="fas fa-flag"></i>Report</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
<button id="subscribe2-{{p.id}}" class="{% if p.id in v.subscribed_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/subscribe/{{p.id}}','subscribe2-{{p.id}}','unsubscribe2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye text-center text-muted mr-3"></i>Subscribe</button>
|
||||
<button id="unsubscribe2-{{p.id}}" class="{% if not p.id in v.subscribed_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/unsubscribe/{{p.id}}','subscribe2-{{p.id}}','unsubscribe2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye-slash text-center text-muted mr-3"></i>Unsubscribe</button>
|
||||
|
||||
<button id="save2-{{p.id}}" class="{% if p.id in v.saved_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/save_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Save</button>
|
||||
<button id="unsave2-{{p.id}}" class="{% if not p.id in v.saved_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/unsave_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Unsave</button>
|
||||
<button id="save2-{{p.id}}" class="{% if p.is_saved(v) %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/save_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Save</button>
|
||||
<button id="unsave2-{{p.id}}" class="{% if not p.is_saved(v) %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/unsave_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Unsave</button>
|
||||
|
||||
|
||||
{% if v.id==p.author_id %}
|
||||
|
|
Loading…
Reference in New Issue