- {% if current_user.is_authenticated and current_user.subscribed(community) %}
+ {% if current_user.is_authenticated and community_membership(current_user, community) == SUBSCRIPTION_MEMBER %}
{{ _('Unsubscribe') }}
+ {% elif current_user.is_authenticated and community_membership(current_user, community) == SUBSCRIPTION_PENDING %}
+
{{ _('Pending') }}
{% else %}
{{ _('Subscribe') }}
{% endif %}
diff --git a/app/templates/email/welcome.html b/app/templates/email/welcome.html
index cd628c8d..e63a12d4 100644
--- a/app/templates/email/welcome.html
+++ b/app/templates/email/welcome.html
@@ -1,11 +1,11 @@
-
+
Hello {{ first_name }} and welcome!
I'm Rimu, the founder of PieFed and I'd like to personally thank you for signing up.
I'd also like to give you the tools and information you need to get the most out of it. Let's get you up and running:
- Helpful resources goes here
-
I hope this helps. For more information please see the FAQ or ask me anything by replying to this email.
+
I hope this helps. For more information please see the FAQ or ask me anything by replying to this email.
Warm regards,
Rimu Atkinson
Founder
diff --git a/app/templates/email/welcome.txt b/app/templates/email/welcome.txt
index 0ed8290b..64e26833 100644
--- a/app/templates/email/welcome.txt
+++ b/app/templates/email/welcome.txt
@@ -6,7 +6,7 @@ I'd also like to give you the tools and information you need to get the most out
1. Helpful resources go here
-I hope this helps. For more information please see the FAQ at https://pyfedi.social/faq.php or ask me anything by replying to this email.
+I hope this helps. For more information please see the FAQ at https://piefed.social/faq.php or ask me anything by replying to this email.
Warm regards,
diff --git a/app/templates/list_communities.html b/app/templates/list_communities.html
index 01f93172..35dfaabd 100644
--- a/app/templates/list_communities.html
+++ b/app/templates/list_communities.html
@@ -50,8 +50,10 @@
{{ community.post_reply_count }} |
{{ moment(community.last_active).fromNow(refresh=True) }} |
{% if current_user.is_authenticated %}
- {% if current_user.subscribed(community) %}
+ {% if community_membership(current_user, community) == SUBSCRIPTION_MEMBER %}
Unsubscribe
+ {% elif community_membership(current_user, community) == SUBSCRIPTION_PENDING %}
+ Pending
{% else %}
Subscribe
{% endif %}
diff --git a/app/templates/post/add_reply.html b/app/templates/post/add_reply.html
index 0a762aeb..bdbe6413 100644
--- a/app/templates/post/add_reply.html
+++ b/app/templates/post/add_reply.html
@@ -21,7 +21,7 @@
- {% if current_user.is_authenticated and current_user.subscribed(post.community) %}
+ {% if current_user.is_authenticated and community_membership(current_user, post.community) %}
{{ _('Unsubscribe') }}
{% else %}
{{ _('Subscribe') }}
diff --git a/app/templates/post/continue_discussion.html b/app/templates/post/continue_discussion.html
index 2ffb9f81..f72fcd2d 100644
--- a/app/templates/post/continue_discussion.html
+++ b/app/templates/post/continue_discussion.html
@@ -61,7 +61,7 @@
- {% if current_user.is_authenticated and current_user.subscribed(post.community) %}
+ {% if current_user.is_authenticated and community_membership(current_user, post.community) %}
{{ _('Unsubscribe') }}
{% else %}
{{ _('Subscribe') }}
diff --git a/app/templates/post/post.html b/app/templates/post/post.html
index 4a41dc13..3b2a8757 100644
--- a/app/templates/post/post.html
+++ b/app/templates/post/post.html
@@ -112,7 +112,7 @@
- {% if current_user.is_authenticated and current_user.subscribed(post.community) %}
+ {% if current_user.is_authenticated and community_membership(current_user, post.community) %}
{{ _('Unsubscribe') }}
{% else %}
{{ _('Subscribe') }}
diff --git a/app/templates/post/post_edit.html b/app/templates/post/post_edit.html
index 44935063..2bcd5338 100644
--- a/app/templates/post/post_edit.html
+++ b/app/templates/post/post_edit.html
@@ -50,8 +50,8 @@
{{ render_field(form.discussion_body) }}
- {{ render_field(form.link_title) }}
{{ render_field(form.link_url) }}
+ {{ render_field(form.link_title) }}
{{ render_field(form.image_title) }}
@@ -63,17 +63,21 @@
{{ render_field(form.type) }}
+
+ {{ render_field(form.notify_author) }}
+
{{ render_field(form.nsfw) }}
{{ render_field(form.nsfl) }}
+
- {{ render_field(form.notify_author) }}
+
{{ render_field(form.submit) }}
diff --git a/app/utils.py b/app/utils.py
index 8050a32a..d3e9be76 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -14,7 +14,7 @@ from flask_login import current_user
from sqlalchemy import text
from app import db, cache
-from app.models import Settings, Domain, Instance, BannedInstances, User
+from app.models import Settings, Domain, Instance, BannedInstances, User, Community
# Flask's render_template function, with support for themes added
@@ -198,6 +198,15 @@ def user_access(permission: str, user_id: int) -> bool:
return has_access is not None
+@cache.memoize(timeout=10)
+def community_membership(user: User, community: Community) -> int:
+ # @cache.memoize works with User.subscribed but cache.delete_memoized does not, making it bad to use on class methods.
+ # however cache.memoize and cache.delete_memoized works fine with normal functions
+ if community is None:
+ return False
+ return user.subscribed(community.id)
+
+
def retrieve_block_list():
try:
response = requests.get('https://github.com/rimu/no-qanon/blob/master/domains.txt', timeout=1)
diff --git a/migrations/versions/b36dac7696d1_save_moderators_url.py b/migrations/versions/b36dac7696d1_save_moderators_url.py
new file mode 100644
index 00000000..0d52cb0a
--- /dev/null
+++ b/migrations/versions/b36dac7696d1_save_moderators_url.py
@@ -0,0 +1,32 @@
+"""save moderators url
+
+Revision ID: b36dac7696d1
+Revises: cae2e31293e8
+Create Date: 2023-12-01 13:02:31.139428
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'b36dac7696d1'
+down_revision = 'cae2e31293e8'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('community', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('ap_moderators_url', sa.String(length=255), nullable=True))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('community', schema=None) as batch_op:
+ batch_op.drop_column('ap_moderators_url')
+
+ # ### end Alembic commands ###
diff --git a/pyfedi.py b/pyfedi.py
index c8e4db7f..9762bc9d 100644
--- a/pyfedi.py
+++ b/pyfedi.py
@@ -6,7 +6,7 @@ from app import create_app, db, cli
import os, click
from flask import session, g, json
from app.constants import POST_TYPE_LINK, POST_TYPE_IMAGE, POST_TYPE_ARTICLE
-from app.utils import getmtime, gibberish, shorten_string, shorten_url, digits, user_access
+from app.utils import getmtime, gibberish, shorten_string, shorten_url, digits, user_access, community_membership
app = create_app()
cli.register(app)
@@ -29,6 +29,7 @@ with app.app_context():
app.jinja_env.globals['len'] = len
app.jinja_env.globals['digits'] = digits
app.jinja_env.globals['str'] = str
+ app.jinja_env.globals['community_membership'] = community_membership
app.jinja_env.globals['json_loads'] = json.loads
app.jinja_env.globals['user_access'] = user_access
app.jinja_env.filters['shorten'] = shorten_string
|