1
1
Fork 0

Removed useless comments, removed test page

master
Jan Kužílek 5 years ago
parent 0ae27c7e9e
commit 70797b990c

@ -40,17 +40,3 @@ def uploaded_big_thumb(*args, **kwargs):
@bp.route('/thumb/<path:path>') @bp.route('/thumb/<path:path>')
def uploaded_smol_thumb(*args, **kwargs): def uploaded_smol_thumb(*args, **kwargs):
return uploaded_img(*args, **kwargs, store=IMAGE_STORE.thumb_smol, exten='jpg') return uploaded_img(*args, **kwargs, store=IMAGE_STORE.thumb_smol, exten='jpg')
@bp.route('/test')
def test():
from yadc.models import Comment
from yadc.forms import CommentForm
comment = Comment.query.get(2)
comment2 = Comment.query.get(5)
comment.editform = CommentForm(id=comment.id, content=comment.content)
comment2.editform = CommentForm(id=comment2.id, content=comment2.content)
return render_template('test.html', comment=comment, comment2=comment2)
# @bp.route('/threads')
# def threads():
# return render_template('post/index.html')

@ -63,23 +63,6 @@ def manage_tags(page):
return render_template('manage/tags.html', tags=tags, elements=tags.items, createform=TagForm()) return render_template('manage/tags.html', tags=tags, elements=tags.items, createform=TagForm())
# @bp.route('/comments', defaults={'page': 1})
# @bp.route('/comments/<int:page>')
# @login_required
# @moderator_required
# def manage_comments(page):
# comments = Comment.query.order_by(Comment.updated).paginate(page, current_app.config.get('MANAGE_PER_PAGE'))
# # for comment in comments.items:
# # comment.editform = CommentForm(
# # id=comment.id,
# # content=comment.content,
# # )
# return render_template('manage/comments.html', tags=comments, elements=comments.items)
# ONLY THROUGH MANAGEMENT # ONLY THROUGH MANAGEMENT
@bp.route('/modify_user', methods=['POST']) @bp.route('/modify_user', methods=['POST'])
@login_required @login_required

@ -117,11 +117,6 @@ def comment():
else: else:
el = Comment.query.filter_by(id=form.id.data).first() el = Comment.query.filter_by(id=form.id.data).first()
# only authors allowed to edit
# if not (el.user and el.user.is_current):
# flash("You don't have sufficient rights to do this.")
# return redirect(url_for('main.index'))
if form.delete.data: if form.delete.data:
db.session.delete(el) db.session.delete(el)
db.session.commit() db.session.commit()
@ -198,26 +193,18 @@ def tag_autocomplete():
return jsonify() return jsonify()
# A TRY TO MAKE A DANBOORU COMPATIBLE API # A TRY TO MAKE A DANBOORU COMPATIBLE API
# import json
@bp.route('/index.json') @bp.route('/index.json')
def posts_api(): def posts_api():
# return jsonify(json.load(open('index.json', 'r')))
# return jsonify(json.load(open('test.json', 'r')))
f_tags = request.args.get('tags', '').split() f_tags = request.args.get('tags', '').split()
# rating = None # no need to filter rating, app filters the content itself (even though sends rating pref)
for t in f_tags: for t in f_tags:
if t.startswith('rating:') or t.startswith('-rating:'): if t.startswith('rating:') or t.startswith('-rating:'):
f_tags.remove(t) f_tags.remove(t)
# rating = t.split(':')[1]
# f_rating = {r.name : r for r in RATING}.get(rating, RATING.safe)
# m_ratings = f_rating.matched
posts_query = Post.query posts_query = Post.query
if f_tags: if f_tags:
posts_query = posts_query.join(Post.tags).group_by(Post.id).filter(Tag.content.in_(f_tags)).having(func.count(Post.id)==len(f_tags)) posts_query = posts_query.join(Post.tags).group_by(Post.id).filter(Tag.content.in_(f_tags)).having(func.count(Post.id)==len(f_tags))
# posts_query = posts_query.filter(Post.rating.in_(m_ratings)).order_by(Post.created.desc())
posts_query = posts_query.filter_by(status=POST_STATUS.active).order_by(Post.created.desc()) posts_query = posts_query.filter_by(status=POST_STATUS.active).order_by(Post.created.desc())
posts = posts_query.paginate(int(request.args.get('page', 0))+1, int(request.args.get('limit') or current_app.config.get('POSTS_PER_PAGE'))) posts = posts_query.paginate(int(request.args.get('page', 0))+1, int(request.args.get('limit') or current_app.config.get('POSTS_PER_PAGE')))

@ -3,7 +3,6 @@ INSTANCE_NAME = 'Darkne.su'
REGISTER_DISABLED = False REGISTER_DISABLED = False
SECRET_KEY = '<place your key here>' SECRET_KEY = '<place your key here>'
# SQLALCHEMY_ECHO = True
SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format('yadc', 'password', 'localhost', 5432, 'yadc') SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format('yadc', 'password', 'localhost', 5432, 'yadc')
MAX_CONTENT_LENGTH = 10*1024*1024 MAX_CONTENT_LENGTH = 10*1024*1024

@ -80,8 +80,6 @@ class UploadForm(CSRFForm):
file.seek(0) file.seek(0)
real_mimetype = Magic(mime=True).from_buffer(file.read()) real_mimetype = Magic(mime=True).from_buffer(file.read())
# flash(client_mimetype)
# flash(real_mimetype)
# if client_mimetype != real_mimetype or client_mimetype not in ['image/png','image/jpeg']: # if client_mimetype != real_mimetype or client_mimetype not in ['image/png','image/jpeg']:
if real_mimetype not in ['image/png','image/jpeg']: if real_mimetype not in ['image/png','image/jpeg']:
raise ValidationError('Please select an image file of PNG or JPEG format.') raise ValidationError('Please select an image file of PNG or JPEG format.')
@ -206,9 +204,4 @@ class CommentForm(EditForm):
# referer = HiddenField() # referer = HiddenField()
ban = SubmitField('Ban') ban = SubmitField('Ban')
unban = SubmitField('Unban') unban = SubmitField('Unban')
# def validate_id(form, field):
# if form.ban.data and not field.data:
# raise ValidationError('ID must be defined to be able to ban.')
# super().validate_id(form, field)

@ -16,7 +16,7 @@ from yadc import db, login, utils
class OP_LEVEL(enum.Enum): class OP_LEVEL(enum.Enum):
user = 0 user = 0
# creator = 1 # IS HE CREATOR OR NOT? # creator = 1
moderator = 5 moderator = 5
admin = 9 admin = 9
@ -42,11 +42,6 @@ class RATING(enum.Enum):
questionable = 1 questionable = 1
explicit = 2 explicit = 2
# @staticmethod
# def matched(rating=None):
# rat = {r.name : r for r in RATING}.get(rating, RATING.safe)
# return [r for r in RATING if r.value<=rat.value]
@property @property
def matched(self): def matched(self):
return [r for r in RATING if r.value<=self.value] return [r for r in RATING if r.value<=self.value]
@ -202,11 +197,6 @@ class Post(TimestampMixin, db.Model):
parent = db.relationship('Post', backref=db.backref('children', lazy=True), remote_side=[id]) parent = db.relationship('Post', backref=db.backref('children', lazy=True), remote_side=[id])
# children = db.relationship('Post', back_populates='parent') # children = db.relationship('Post', back_populates='parent')
# def __init__(self, **kwargs):
# super().__init__(**kwargs)
# self.generate_image_files()
@property @property
def resolution(self): def resolution(self):
return (self.width, self.height) return (self.width, self.height)

@ -72,7 +72,5 @@
{% assets "js_all" %} {% assets "js_all" %}
<script src="{{ ASSET_URL }}"></script> <script src="{{ ASSET_URL }}"></script>
{% endassets %} {% endassets %}
{#<script src="{{ url_for('static', filename="base.js") }}"></script>
<script src="{{ url_for('static', filename="management.js") }}"></script>#}
</body> </body>
</html> </html>

@ -45,19 +45,4 @@
{% call genfield() %} {% call genfield() %}
{{ element.last_login.strftime('%I:%M %p %d %b, %Y') if element.last_login else 'Not yet logged in' }} {{ element.last_login.strftime('%I:%M %p %d %b, %Y') if element.last_login else 'Not yet logged in' }}
{% endcall %} {% endcall %}
{% endblock %} {% endblock %}
{#{% block createform %}
<tr>
<form action="{{ url_for('manage.modify_user') }}" method="post">
{{ createform.csrf_token }}
{{ createform.id() }}
<td></td>
<td>{{ createform.username() }}</td>
<td>{{ createform.user_status() }}</td>
<td>{{ createform.op_level() }}</td>
<td></td>
<td>{{ createform.create() }}</td>
</form>
</tr>
{% endblock %}#}

@ -1,97 +0,0 @@
{% extends 'layout/base.html' %}
{% from '_includes.html' import render_comment with context %}
{% block content %}
<div class="tag-input">
<div class="tag-container tags-inpage">
<a class="taginpage" data-tagname="test" href="bruh">
<span class="tag-icon">
<span class="fa fa-tag"></span>
</span>
<span class="content">
bruuuuuuuuuuuh
{#<!-- <span class="name">test</span> -->#}
</span>
<span class="count">12</span>
<span class="tag-right">
<!-- <span class="fa fa-plus plus"></span> -->
<span class="fa fa-close close"></span>
</span>
</a>
<a class="taginpage" data-tagname="test" href="bruh">
<span class="tag-icon">
<span class="fa fa-tag"></span>
</span>
<span class="content">
bruuuuuuuuuuuh
{#<!-- <span class="name">test</span> -->#}
</span>
<span class="count">12</span>
<span class="tag-right">
<span class="fa fa-plus plus"></span>
<!-- <span class="fa fa-close close"></span> -->
</span>
</a>
<a class="taginpage" data-tagname="test" href="bruh">
<span class="tag-icon">
<span class="fa fa-tag"></span>
</span>
<span class="content">
bruuuuuuuuuuuh
{#<!-- <span class="name">test</span> -->#}
</span>
<!-- <span class="count">12</span> -->
<span class="tag-right">
<!-- <span class="fa fa-plus plus"></span> -->
<span class="fa fa-close close"></span>
</span>
</a>
</div>
</div>
<div class="comment-container" style="border: 1px solid white;">
<article class="comment editingable" style="border: 1px solid red;">
<form action="{{ url_for('post.comment') }}" method="post">
{{ comment.editform.csrf_token }}
{{ comment.editform.id() }}
<div class="comment-head">
<h4>{{ comment.user.username or "Deleted account" }}</h4>
<span class="controls">
{% if current_user.is_moderator %}
{% if not comment.deleted %}
<a class="control-moderate"><label>ban{{ comment.editform.ban() }}</label></a>
{% else %}
<a class="control-moderate"><label>unban{{ comment.editform.unban() }}</label></a>
{% endif %}
{% endif %}
{% if comment.is_author %}
<a class="jsoff-show edit"><label>delete{{ comment.editform.delete() }}</label></a>
<a class="jsoff-show edit"><label>submit{{ comment.editform.edit() }}</label></a>
<a class="jsoff-hide notedit control-edit"><label>edit</label></a>
<a class="jsoff-hide edit control-edit"><label>cancel</label></a>
{% endif %}
</span>
</div>
<div class="comment-editform baseform">
{% if not comment.deleted or comment.is_author or current_user.is_moderator %}
<p class="{%if comment.is_author%}jsoff-show {%endif%}comment-content notedit">{{ comment.content }}</p>
{% endif %}
{% if comment.deleted %}
<p class="deleted">[Comment banned]</p>
{% endif %}
{% if comment.is_author %}
{{ comment.editform.content(class="jsoff-show edit") }}
{% endif %}
</div>
</form>
</article>
{{ render_comment(comment2, comment2.editform) }}
</div>
{% endblock %}

@ -1,11 +1,6 @@
{% extends 'layout/base.html' %} {% extends 'layout/base.html' %}
{% from '_includes.html' import render_comment with context %} {% from '_includes.html' import render_comment with context %}
{#{% block sidebar %}
{{ super()}}
{% endblock %}#}
{% block content %} {% block content %}
<div class="user-main"> <div class="user-main">
<h1 class="username">{{ user.username }}</h1> <h1 class="username">{{ user.username }}</h1>

Loading…
Cancel
Save