redoing cli, getting basic mod queue going, setting up profile, etc
parent
2a9b1995ce
commit
ba76f9e5bb
@ -0,0 +1,51 @@
|
|||||||
|
import click
|
||||||
|
from flask import Blueprint
|
||||||
|
|
||||||
|
from suchwowx.models import Moderator, User
|
||||||
|
from suchwowx.factory import db
|
||||||
|
|
||||||
|
|
||||||
|
bp = Blueprint('mod', 'mod')
|
||||||
|
|
||||||
|
@bp.cli.command('list')
|
||||||
|
def list():
|
||||||
|
"""
|
||||||
|
List current server moderators.
|
||||||
|
"""
|
||||||
|
for mod in Moderator.query.all():
|
||||||
|
click.echo(mod.user.handle)
|
||||||
|
|
||||||
|
@bp.cli.command('add')
|
||||||
|
@click.argument('moderator_handle')
|
||||||
|
def add(moderator_handle):
|
||||||
|
"""
|
||||||
|
Add server moderators by user handle.
|
||||||
|
"""
|
||||||
|
user = User.query.filter(User.handle == moderator_handle).first()
|
||||||
|
if user:
|
||||||
|
mod = Moderator.query.filter(Moderator.user_id == user.id).first()
|
||||||
|
if mod is None:
|
||||||
|
m = Moderator(user_id=user.id)
|
||||||
|
db.session.add(m)
|
||||||
|
db.session.commit()
|
||||||
|
click.echo(f'[+] Added moderator status to `{moderator_handle}`')
|
||||||
|
else:
|
||||||
|
click.echo('[.] That is not a valid user.')
|
||||||
|
|
||||||
|
@bp.cli.command('remove')
|
||||||
|
@click.argument('moderator_handle')
|
||||||
|
def remove(moderator_handle):
|
||||||
|
"""
|
||||||
|
Remove server moderator by user handle.
|
||||||
|
"""
|
||||||
|
user = User.query.filter(User.handle == moderator_handle).first()
|
||||||
|
if user:
|
||||||
|
mod = Moderator.query.filter(Moderator.user_id == user.id).first()
|
||||||
|
if mod:
|
||||||
|
db.session.delete(mod)
|
||||||
|
db.session.commit()
|
||||||
|
click.echo(f'[-] Removed moderator status from `{moderator_handle}`')
|
||||||
|
else:
|
||||||
|
click.echo(f'[.] That user is not a moderator.')
|
||||||
|
else:
|
||||||
|
click.echo('[.] That is not a valid user.')
|
@ -0,0 +1,16 @@
|
|||||||
|
from flask import Blueprint, render_template
|
||||||
|
from flask import redirect, url_for
|
||||||
|
from flask_login import logout_user
|
||||||
|
|
||||||
|
from suchwowx.models import User
|
||||||
|
from suchwowx import config
|
||||||
|
|
||||||
|
|
||||||
|
bp = Blueprint('user', 'user')
|
||||||
|
|
||||||
|
@bp.route('/user/<handle>')
|
||||||
|
def show(handle):
|
||||||
|
user = User.query.filter(User.handle == handle).first()
|
||||||
|
if not user:
|
||||||
|
return redirect(url_for('meme.index'))
|
||||||
|
return render_template('profile.html', user=user)
|
@ -0,0 +1,36 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
{% include 'includes/head.html' %}
|
||||||
|
<body>
|
||||||
|
<section class="section">
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
{% include 'includes/navbar.html' %}
|
||||||
|
|
||||||
|
{% if user %}
|
||||||
|
<div id="screen">
|
||||||
|
<div class="screen">
|
||||||
|
<p><strong>From Avax Chain</strong></p>
|
||||||
|
<p>Handle: <input type="text" placeholder="{{ user.handle }}" value="{{ user.handle }}"></input>
|
||||||
|
<img src="{{ user.get_profile_image() }}" id="profileImage" />
|
||||||
|
</br></br>
|
||||||
|
<p><strong>From Local Database</strong></p>
|
||||||
|
<p>Register Date: <strong>{{ user.register_date }}</strong></p>
|
||||||
|
<p>Login Date: <strong>{{ user.last_login_date }}</strong></p>
|
||||||
|
<p>Moderator: <strong>{{ user.is_moderator() }}</strong></p>
|
||||||
|
<p>Verified: <strong>{{ user.verified }}</strong></p>
|
||||||
|
{% if user.bio %}
|
||||||
|
<p>Bio: {{ user.bio }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if user.website %}
|
||||||
|
<p>Website: <a href="{{ user.website_url }}" target="_blank">{{ user.website_url }}</a></p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,59 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
{% include 'includes/head.html' %}
|
||||||
|
<body>
|
||||||
|
<section class="section">
|
||||||
|
<div class="container">
|
||||||
|
{% include 'includes/navbar.html' %}
|
||||||
|
|
||||||
|
{% if memes %}
|
||||||
|
{% for _meme in memes | batch(4) %}
|
||||||
|
<div class="columns">
|
||||||
|
|
||||||
|
{% for meme in _meme %}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-image">
|
||||||
|
<figure class="image">
|
||||||
|
<a href="{{ url_for('meme.meme', meme_id=meme.id) }}" up-preload up-follow=".container">
|
||||||
|
{% if meme.file_name.endswith('mp4') %}
|
||||||
|
<video class="img-fluid" {% if not request.MOBILE %}autoplay{% else %}controls{% endif %} muted loop>
|
||||||
|
<source src="{{ url_for('meta.uploaded_file', filename=meme.file_name) }}" type="video/mp4">
|
||||||
|
Your browser does not support the video tag.
|
||||||
|
</video>
|
||||||
|
{% else %}
|
||||||
|
<img alt="{{ meme.title }}" src="{{ url_for('meta.uploaded_file', filename=meme.file_name) }}" width="200px" class="img-fluid" style="" />
|
||||||
|
{% endif %}
|
||||||
|
</a>
|
||||||
|
</figure>
|
||||||
|
</div>
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="media">
|
||||||
|
<div class="media-left">
|
||||||
|
<!-- <figure class="image is-48x48">
|
||||||
|
<img src="https://bulma.io/images/placeholders/96x96.png" alt="Placeholder image">
|
||||||
|
</figure> -->
|
||||||
|
</div>
|
||||||
|
<div class="media-content">
|
||||||
|
<p class="title is-4">John Smith</p>
|
||||||
|
<p class="subtitle is-6">@johnsmith</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
{{ meme.description }}
|
||||||
|
<br>
|
||||||
|
<time datetime="2016-1-1">{{ meme.create_date.strftime('%H:%M UTC - %d %b %Y') }}</time>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% include 'includes/footer.html' %}
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue