mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
Merge pull request 'improve about page' (#151) from rscmbbng/pyfedi:main into main
Reviewed-on: https://codeberg.org/rimu/pyfedi/pulls/151
This commit is contained in:
commit
384f6e0903
6 changed files with 25 additions and 23 deletions
|
@ -1,7 +1,7 @@
|
|||
from flask_wtf import FlaskForm
|
||||
from flask_wtf.file import FileRequired, FileAllowed
|
||||
from sqlalchemy import func
|
||||
from wtforms import StringField, PasswordField, SubmitField, HiddenField, BooleanField, TextAreaField, SelectField, \
|
||||
from wtforms import StringField, PasswordField, SubmitField, EmailField, HiddenField, BooleanField, TextAreaField, SelectField, \
|
||||
FileField, IntegerField
|
||||
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length, Optional
|
||||
from flask_babel import _, lazy_gettext as _l
|
||||
|
@ -17,6 +17,7 @@ class SiteProfileForm(FlaskForm):
|
|||
])
|
||||
sidebar = TextAreaField(_l('Sidebar'))
|
||||
legal_information = TextAreaField(_l('Legal information'))
|
||||
contact_email = EmailField(_l('General instance contact email address'), validators=[Email(), DataRequired(), Length(min=5, max=255)])
|
||||
submit = SubmitField(_l('Save'))
|
||||
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ def admin_site():
|
|||
site.sidebar = form.sidebar.data
|
||||
site.legal_information = form.legal_information.data
|
||||
site.updated = utcnow()
|
||||
site.contact_email = form.contact_email.data
|
||||
if site.id is None:
|
||||
db.session.add(site)
|
||||
db.session.commit()
|
||||
|
|
|
@ -10,7 +10,7 @@ from sqlalchemy.sql.operators import or_, and_
|
|||
|
||||
from app import db, cache
|
||||
from app.activitypub.util import default_context, make_image_sizes_async, refresh_user_profile, find_actor_or_create, \
|
||||
refresh_community_profile_task
|
||||
refresh_community_profile_task, users_total, active_month, local_posts, local_communities, local_comments
|
||||
from app.constants import SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER, POST_TYPE_IMAGE, POST_TYPE_LINK, \
|
||||
SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR, POST_TYPE_VIDEO
|
||||
from app.email import send_email, send_welcome_email
|
||||
|
@ -49,7 +49,6 @@ def index(sort=None):
|
|||
def popular(sort=None):
|
||||
return home_page('popular', sort)
|
||||
|
||||
|
||||
@bp.route('/all', methods=['GET'])
|
||||
@bp.route('/all/<sort>', methods=['GET'])
|
||||
def all_posts(sort=None):
|
||||
|
@ -242,19 +241,17 @@ def donate():
|
|||
@bp.route('/about')
|
||||
def about_page():
|
||||
|
||||
users = User.query.filter_by(ap_id=None, deleted=False, banned=False).all()
|
||||
user_amount = len(users)
|
||||
# Todo, figure out how to filter the user list with the list of user_role user_id == 4
|
||||
#admins = users.filter()
|
||||
# Todo, figure out how to filter the user list with the list of user_role user_id == 4
|
||||
#staff = users.filter()
|
||||
|
||||
domains_amount = len(Domain.query.filter_by(banned=False).all())
|
||||
community_amount = len(Community.query.all())
|
||||
user_amount = users_total()
|
||||
MAU = active_month()
|
||||
posts_amount = local_posts()
|
||||
|
||||
admins = db.session.execute(text('SELECT user_name, email FROM "user" WHERE "id" IN (SELECT "user_id" FROM "user_role" WHERE "role_id" = 4) ORDER BY id')).all()
|
||||
staff = db.session.execute(text('SELECT user_name FROM "user" WHERE "id" IN (SELECT "user_id" FROM "user_role" WHERE "role_id" = 2) ORDER BY id')).all()
|
||||
domains_amount = db.session.execute(text('SELECT COUNT(id) as c FROM "domain" WHERE "banned" IS false')).scalar()
|
||||
community_amount = local_communities()
|
||||
instance = Instance.query.filter_by(id=1).first()
|
||||
|
||||
|
||||
return render_template('about.html', user_amount=user_amount, domains_amount=domains_amount, community_amount=community_amount, instance=instance)#, admins=admins)
|
||||
return render_template('about.html', user_amount=user_amount, mau=MAU, posts_amount=posts_amount, domains_amount=domains_amount, community_amount=community_amount, instance=instance, admins=admins, staff=staff)
|
||||
|
||||
|
||||
@bp.route('/privacy')
|
||||
|
|
|
@ -8,16 +8,18 @@
|
|||
<div class="row">
|
||||
<div class="col-12 col-md-8 position-relative main_pane">
|
||||
<h1>{{ _('About %(site_name)s', site_name=g.site.name) }}</h1>
|
||||
|
||||
<p> {{g.site.name}} is a <a href="https://join.piefed.social/">pyfedi</a> instance created on {{instance.created_at}}. It is home to <a href="/people">{{user_amount}} users</a>, <a href="/communities/local"> {{community_amount}} communities</a> who discussed <a href="/domains">{{domains_amount}} domains</a>. This instance is administerred and staffed by $PLACEHOLDER_ADMINS and $PLACEHOLDER_STAFF.</p>
|
||||
<p> {{g.site.name}} is a <a href="https://join.piefed.social/">pyfedi</a> instance created on {{instance.created_at.strftime('%d-%m-%Y')}}. It is home to <a href="/people">{{user_amount}} users</a> (of which {{mau}} active in the last month). In the <a href="/communities/local"> {{community_amount}} communities</a> we discussed <a href="/domains">{{domains_amount}} domains</a> and made {{posts_amount}} posts.</p>
|
||||
<h2> Team </h2>
|
||||
<p>This instance is administerred by {% for admin in admins %}<a href="/u/{{ admin.user_name }}">{{ admin.user_name }}</a>{{ ", " if not loop.last }}{% endfor %}.</p>
|
||||
<p>It is moderated by {% for s in staff %}<a href="/u/{{ s.user_name }}">{{ s.user_name }}</a>{{ ", " if not loop.last }}{% endfor %}.</p>
|
||||
<h2>Contact</h2>
|
||||
<p>Placeholder Admin email</p>
|
||||
<p>{{g.site.contact_email | safe }}</p>
|
||||
<h2> About Us </h2>
|
||||
<p> {{g.site.description | safe}} </p>
|
||||
<p> {{g.site.sidebar}} </p>
|
||||
<p> {{g.site.description | safe }} </p>
|
||||
<p> {{g.site.sidebar | safe }} </p>
|
||||
{% if g.site.legal_information %}
|
||||
<h2> Legal Information </h2>
|
||||
<p> {{g.site.legal_information}} </p>
|
||||
<p> {{g.site.legal_information | safe }} </p>
|
||||
<p> <a href="/privacy"> Our Privacy Policy </a> </p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<p class="small field_hint">HTML is allowed in this field.</p>
|
||||
{{ render_field(form.legal_information) }}
|
||||
<p class="small field_hint">HTML is allowed in this field.</p>
|
||||
{{ render_field(form.contact_email) }}
|
||||
{{ render_field(form.submit) }}
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -50,6 +50,6 @@ class Config(object):
|
|||
CLOUDFLARE_API_TOKEN = os.environ.get('CLOUDFLARE_API_TOKEN') or ''
|
||||
CLOUDFLARE_ZONE_ID = os.environ.get('CLOUDFLARE_ZONE_ID') or ''
|
||||
|
||||
SPICY_UNDER_10 = float(os.environ.get('SPICY_UNDER_10')) or 1.0
|
||||
SPICY_UNDER_30 = float(os.environ.get('SPICY_UNDER_30')) or 1.0
|
||||
SPICY_UNDER_60 = float(os.environ.get('SPICY_UNDER_60')) or 1.0
|
||||
SPICY_UNDER_10 = float(os.environ.get('SPICY_UNDER_10', 1.0))
|
||||
SPICY_UNDER_30 = float(os.environ.get('SPICY_UNDER_30', 1.0))
|
||||
SPICY_UNDER_60 = float(os.environ.get('SPICY_UNDER_60', 1.0))
|
||||
|
|
Loading…
Add table
Reference in a new issue