Adding a pre-load of threadiverse communities to the admin area

This commit is contained in:
Alan Roberts 2024-09-11 19:14:12 -04:00
parent 6970f15e4c
commit 3838ad5701
3 changed files with 18 additions and 3 deletions

View file

@ -51,6 +51,8 @@ class FederationForm(FlaskForm):
blocked_actors = TextAreaField(_l('Discard all posts and comments by users with these words in their name (one per line)')) blocked_actors = TextAreaField(_l('Discard all posts and comments by users with these words in their name (one per line)'))
submit = SubmitField(_l('Save')) submit = SubmitField(_l('Save'))
class PreLoadCommunitiesForm(FlaskForm):
pre_load_submit = SubmitField(_l('Add Communities'))
class EditCommunityForm(FlaskForm): class EditCommunityForm(FlaskForm):
title = StringField(_l('Title'), validators=[DataRequired()]) title = StringField(_l('Title'), validators=[DataRequired()])

View file

@ -15,7 +15,7 @@ from app.activitypub.routes import process_inbox_request, process_delete_request
from app.activitypub.signature import post_request, default_context from app.activitypub.signature import post_request, default_context
from app.activitypub.util import instance_allowed, instance_blocked from app.activitypub.util import instance_allowed, instance_blocked
from app.admin.forms import FederationForm, SiteMiscForm, SiteProfileForm, EditCommunityForm, EditUserForm, \ from app.admin.forms import FederationForm, SiteMiscForm, SiteProfileForm, EditCommunityForm, EditUserForm, \
EditTopicForm, SendNewsletterForm, AddUserForm EditTopicForm, SendNewsletterForm, AddUserForm, PreLoadCommunitiesForm
from app.admin.util import unsubscribe_from_everything_then_delete, unsubscribe_from_community, send_newsletter, \ from app.admin.util import unsubscribe_from_everything_then_delete, unsubscribe_from_community, send_newsletter, \
topics_for_form topics_for_form
from app.community.util import save_icon_file, save_banner_file from app.community.util import save_icon_file, save_banner_file
@ -190,12 +190,17 @@ def admin_misc():
@permission_required('change instance settings') @permission_required('change instance settings')
def admin_federation(): def admin_federation():
form = FederationForm() form = FederationForm()
preload_form = PreLoadCommunitiesForm()
site = Site.query.get(1) site = Site.query.get(1)
if site is None: if site is None:
site = Site() site = Site()
# todo: finish form # todo: finish form
site.updated = utcnow() site.updated = utcnow()
if form.validate_on_submit(): if preload_form.pre_load_submit.data and preload_form.validate():
flash(_('add communities button clicked'))
return redirect(url_for('admin.admin_federation'))
elif form.validate_on_submit():
if form.use_allowlist.data: if form.use_allowlist.data:
set_setting('use_allowlist', True) set_setting('use_allowlist', True)
db.session.execute(text('DELETE FROM allowed_instances')) db.session.execute(text('DELETE FROM allowed_instances'))
@ -228,7 +233,8 @@ def admin_federation():
form.blocked_phrases.data = site.blocked_phrases form.blocked_phrases.data = site.blocked_phrases
form.blocked_actors.data = get_setting('actor_blocked_words', '88') form.blocked_actors.data = get_setting('actor_blocked_words', '88')
return render_template('admin/federation.html', title=_('Federation settings'), form=form, return render_template('admin/federation.html', title=_('Federation settings'),
form=form, preload_form=preload_form,
moderating_communities=moderating_communities(current_user.get_id()), moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(), menu_topics=menu_topics(),

View file

@ -15,6 +15,13 @@
</div> </div>
</div> </div>
<hr /> <hr />
<div class="row">
<div class="column">
<p>Use this to "pre-load" the top 50 known threadiverse communities, as rnaked by posts and activity. The list of communities pulls from the same list as <a href="https://lemmyverse.net/communities">LemmyVerse</a>. NSFW communities and communities from banned instances are excluded.</p>
{{ render_form(preload_form) }}
</div>
</div>
<hr />
<div class="row"> <div class="row">
<div class="col"> <div class="col">
{% include 'admin/_nav.html' %} {% include 'admin/_nav.html' %}