mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
fix join/leave buttons
This commit is contained in:
parent
c6216f2588
commit
0d9566806e
6 changed files with 14 additions and 9 deletions
|
@ -11,7 +11,7 @@ from app.community.forms import SearchRemoteCommunity, AddLocalCommunity, Create
|
|||
from app.community.util import search_for_community, community_url_exists, actor_to_community, \
|
||||
opengraph_parse, url_to_thumbnail_file, save_post, save_icon_file, save_banner_file, send_to_remote_instance
|
||||
from app.constants import SUBSCRIPTION_MEMBER, SUBSCRIPTION_OWNER, POST_TYPE_LINK, POST_TYPE_ARTICLE, POST_TYPE_IMAGE, \
|
||||
SUBSCRIPTION_PENDING
|
||||
SUBSCRIPTION_PENDING, SUBSCRIPTION_MODERATOR
|
||||
from app.models import User, Community, CommunityMember, CommunityJoinRequest, CommunityBan, Post, \
|
||||
File, PostVote, utcnow, Report, Notification, InstanceBlock, ActivityPubLog
|
||||
from app.community import bp
|
||||
|
@ -141,7 +141,8 @@ def show_community(community: Community):
|
|||
return render_template('community/community.html', community=community, title=community.title,
|
||||
is_moderator=is_moderator, is_owner=is_owner, is_admin=is_admin, mods=mod_list, posts=posts, description=description,
|
||||
og_image=og_image, POST_TYPE_IMAGE=POST_TYPE_IMAGE, POST_TYPE_LINK=POST_TYPE_LINK, SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING,
|
||||
SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER, etag=f"{community.id}_{hash(community.last_active)}",
|
||||
SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
|
||||
etag=f"{community.id}_{hash(community.last_active)}",
|
||||
next_url=next_url, prev_url=prev_url, low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1',
|
||||
rss_feed=f"https://{current_app.config['SERVER_NAME']}/community/{community.link()}/feed", rss_feed_name=f"{community.title} posts on PieFed",
|
||||
content_filters=content_filters)
|
||||
|
|
|
@ -5,7 +5,8 @@ from sqlalchemy.sql.operators import or_
|
|||
|
||||
from app import db, cache
|
||||
from app.activitypub.util import default_context, make_image_sizes_async, refresh_user_profile
|
||||
from app.constants import SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER, POST_TYPE_IMAGE, POST_TYPE_LINK, SUBSCRIPTION_OWNER
|
||||
from app.constants import SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER, POST_TYPE_IMAGE, POST_TYPE_LINK, \
|
||||
SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR
|
||||
from app.main import bp
|
||||
from flask import g, session, flash, request, current_app, url_for, redirect, make_response, jsonify
|
||||
from flask_moment import moment
|
||||
|
@ -162,7 +163,8 @@ def list_communities():
|
|||
|
||||
return render_template('list_communities.html', communities=communities.order_by(sort_by).all(), search=search_param, title=_('Communities'),
|
||||
SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,
|
||||
SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, topics=topics, topic_id=topic_id, sort_by=sort_by,
|
||||
SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
|
||||
topics=topics, topic_id=topic_id, sort_by=sort_by,
|
||||
low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1')
|
||||
|
||||
|
||||
|
@ -173,6 +175,7 @@ def list_local_communities():
|
|||
communities = Community.query.filter_by(ap_id=None, banned=False)
|
||||
return render_template('list_communities.html', communities=communities.order_by(sort_by).all(), title=_('Local communities'), sort_by=sort_by,
|
||||
SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,
|
||||
SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
|
||||
low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1')
|
||||
|
||||
|
||||
|
@ -186,6 +189,7 @@ def list_subscribed_communities():
|
|||
communities = []
|
||||
return render_template('list_communities.html', communities=communities.order_by(sort_by).all(), title=_('Joined communities'),
|
||||
SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER, sort_by=sort_by,
|
||||
SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
|
||||
low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1')
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from app.community.util import save_post, send_to_remote_instance
|
|||
from app.post.forms import NewReplyForm, ReportPostForm, MeaCulpaForm
|
||||
from app.community.forms import CreatePostForm
|
||||
from app.post.util import post_replies, get_comment_branch, post_reply_count
|
||||
from app.constants import SUBSCRIPTION_MEMBER, SUBSCRIPTION_OWNER, POST_TYPE_LINK, POST_TYPE_ARTICLE, POST_TYPE_IMAGE
|
||||
from app.constants import SUBSCRIPTION_MEMBER
|
||||
from app.models import Post, PostReply, \
|
||||
PostReplyVote, PostVote, Notification, utcnow, UserBlock, DomainBlock, InstanceBlock, Report, Site, Community
|
||||
from app.post import bp
|
||||
|
@ -178,7 +178,7 @@ def show_post(post_id: int):
|
|||
description=description, og_image=og_image, POST_TYPE_IMAGE=constants.POST_TYPE_IMAGE,
|
||||
POST_TYPE_LINK=constants.POST_TYPE_LINK, POST_TYPE_ARTICLE=constants.POST_TYPE_ARTICLE,
|
||||
etag=f"{post.id}_{hash(post.last_active)}", markdown_editor=True,
|
||||
low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1')
|
||||
low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1', SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER)
|
||||
|
||||
|
||||
@bp.route('/post/<int:post_id>/<vote_direction>', methods=['GET', 'POST'])
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
<a class="w-100 btn btn-primary" href="/community/{{ community.link() }}/submit">{{ _('Create a post') }}</a>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
{% if current_user.is_authenticated and community_membership(current_user, community) == SUBSCRIPTION_MEMBER %}
|
||||
{% if current_user.is_authenticated and community_membership(current_user, community) in [SUBSCRIPTION_MEMBER, SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER] %}
|
||||
<a class="w-100 btn btn-primary" href="/community/{{ community.link() }}/unsubscribe">{{ _('Leave') }}</a>
|
||||
{% elif current_user.is_authenticated and community_membership(current_user, community) == SUBSCRIPTION_PENDING %}
|
||||
<a class="w-100 btn btn-outline-secondary" href="/community/{{ community.link() }}/unsubscribe">{{ _('Pending') }}</a>
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
{% for community in communities %}
|
||||
<tr class="">
|
||||
<td width="70">{% if current_user.is_authenticated %}
|
||||
{% if community_membership(current_user, community) in [SUBSCRIPTION_MEMBER, SUBSCRIPTION_OWNER] %}
|
||||
{% if community_membership(current_user, community) in [SUBSCRIPTION_MEMBER, SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER] %}
|
||||
<a class="btn btn-primary btn-sm" href="/community/{{ community.link() }}/unsubscribe">{{ _('Leave') }}</a>
|
||||
{% elif community_membership(current_user, community) == SUBSCRIPTION_PENDING %}
|
||||
<a class="btn btn-outline-secondary btn-sm" href="/community/{{ community.link() }}/unsubscribe">{{ _('Pending') }}</a>
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
<a class="w-100 btn btn-primary" href="/community/{{ post.community.link() }}/submit">{{ _('Create post') }}</a>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
{% if current_user.is_authenticated and community_membership(current_user, post.community) %}
|
||||
{% if current_user.is_authenticated and community_membership(current_user, post.community) >= SUBSCRIPTION_MEMBER %}
|
||||
<a class="w-100 btn btn-primary" href="/community/{{ post.community.link() }}/unsubscribe">{{ _('Leave') }}</a>
|
||||
{% else %}
|
||||
<a class="w-100 btn btn-primary" href="/community/{{ post.community.link() }}/subscribe">{{ _('Join') }}</a>
|
||||
|
|
Loading…
Add table
Reference in a new issue