From 70797b990c525279f73dd8c3b9b9ff88ad16a15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C5=BE=C3=ADlek?= Date: Thu, 14 May 2020 19:37:28 +0200 Subject: [PATCH] Removed useless comments, removed test page --- yadc/bp/main.py | 14 ----- yadc/bp/manage.py | 17 ------ yadc/bp/post.py | 15 +---- yadc/config.def.py | 1 - yadc/forms.py | 9 +-- yadc/models.py | 12 +--- yadc/templates/layout/base.html | 2 - yadc/templates/manage/users.html | 17 +----- yadc/templates/test.html | 97 -------------------------------- yadc/templates/user/profile.html | 5 -- 10 files changed, 4 insertions(+), 185 deletions(-) delete mode 100644 yadc/templates/test.html diff --git a/yadc/bp/main.py b/yadc/bp/main.py index 9f8d9ac..faf04f7 100644 --- a/yadc/bp/main.py +++ b/yadc/bp/main.py @@ -40,17 +40,3 @@ def uploaded_big_thumb(*args, **kwargs): @bp.route('/thumb/') def uploaded_smol_thumb(*args, **kwargs): 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') diff --git a/yadc/bp/manage.py b/yadc/bp/manage.py index 8b08a05..d00825f 100644 --- a/yadc/bp/manage.py +++ b/yadc/bp/manage.py @@ -63,23 +63,6 @@ def manage_tags(page): return render_template('manage/tags.html', tags=tags, elements=tags.items, createform=TagForm()) -# @bp.route('/comments', defaults={'page': 1}) -# @bp.route('/comments/') -# @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 @bp.route('/modify_user', methods=['POST']) @login_required diff --git a/yadc/bp/post.py b/yadc/bp/post.py index d8fcbdf..ae21023 100644 --- a/yadc/bp/post.py +++ b/yadc/bp/post.py @@ -117,11 +117,6 @@ def comment(): else: 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: db.session.delete(el) db.session.commit() @@ -198,26 +193,18 @@ def tag_autocomplete(): return jsonify() # A TRY TO MAKE A DANBOORU COMPATIBLE API -# import json @bp.route('/index.json') 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() - # rating = None + # no need to filter rating, app filters the content itself (even though sends rating pref) for t in f_tags: if t.startswith('rating:') or t.startswith('-rating:'): 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 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.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 = posts_query.paginate(int(request.args.get('page', 0))+1, int(request.args.get('limit') or current_app.config.get('POSTS_PER_PAGE'))) diff --git a/yadc/config.def.py b/yadc/config.def.py index 9dcce64..5e83026 100644 --- a/yadc/config.def.py +++ b/yadc/config.def.py @@ -3,7 +3,6 @@ INSTANCE_NAME = 'Darkne.su' REGISTER_DISABLED = False SECRET_KEY = '' -# SQLALCHEMY_ECHO = True SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format('yadc', 'password', 'localhost', 5432, 'yadc') MAX_CONTENT_LENGTH = 10*1024*1024 diff --git a/yadc/forms.py b/yadc/forms.py index 0c140d1..ae8f4b6 100644 --- a/yadc/forms.py +++ b/yadc/forms.py @@ -80,8 +80,6 @@ class UploadForm(CSRFForm): file.seek(0) 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 real_mimetype not in ['image/png','image/jpeg']: raise ValidationError('Please select an image file of PNG or JPEG format.') @@ -206,9 +204,4 @@ class CommentForm(EditForm): # referer = HiddenField() ban = SubmitField('Ban') - 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) \ No newline at end of file + unban = SubmitField('Unban') \ No newline at end of file diff --git a/yadc/models.py b/yadc/models.py index 28d1855..a2b4467 100644 --- a/yadc/models.py +++ b/yadc/models.py @@ -16,7 +16,7 @@ from yadc import db, login, utils class OP_LEVEL(enum.Enum): user = 0 - # creator = 1 # IS HE CREATOR OR NOT? + # creator = 1 moderator = 5 admin = 9 @@ -42,11 +42,6 @@ class RATING(enum.Enum): questionable = 1 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 def matched(self): 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]) # children = db.relationship('Post', back_populates='parent') - # def __init__(self, **kwargs): - # super().__init__(**kwargs) - - # self.generate_image_files() - @property def resolution(self): return (self.width, self.height) diff --git a/yadc/templates/layout/base.html b/yadc/templates/layout/base.html index 29e7d6a..6a7c5d6 100644 --- a/yadc/templates/layout/base.html +++ b/yadc/templates/layout/base.html @@ -72,7 +72,5 @@ {% assets "js_all" %} {% endassets %} - {# - #} \ No newline at end of file diff --git a/yadc/templates/manage/users.html b/yadc/templates/manage/users.html index ddb129b..e0a7d3e 100644 --- a/yadc/templates/manage/users.html +++ b/yadc/templates/manage/users.html @@ -45,19 +45,4 @@ {% call genfield() %} {{ element.last_login.strftime('%I:%M %p %d %b, %Y') if element.last_login else 'Not yet logged in' }} {% endcall %} -{% endblock %} - -{#{% block createform %} - -
- {{ createform.csrf_token }} - {{ createform.id() }} - - {{ createform.username() }} - {{ createform.user_status() }} - {{ createform.op_level() }} - - {{ createform.create() }} -
- -{% endblock %}#} \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/yadc/templates/test.html b/yadc/templates/test.html deleted file mode 100644 index 32d04a5..0000000 --- a/yadc/templates/test.html +++ /dev/null @@ -1,97 +0,0 @@ -{% extends 'layout/base.html' %} -{% from '_includes.html' import render_comment with context %} - -{% block content %} - - -
-
-
- {{ comment.editform.csrf_token }} - {{ comment.editform.id() }} -
-

{{ comment.user.username or "Deleted account" }}

- - {% if current_user.is_moderator %} - {% if not comment.deleted %} - - {% else %} - - {% endif %} - {% endif %} - {% if comment.is_author %} - - - - - - {% endif %} - -
- -
- {% if not comment.deleted or comment.is_author or current_user.is_moderator %} -

{{ comment.content }}

- {% endif %} - {% if comment.deleted %} -

[Comment banned]

- {% endif %} - - {% if comment.is_author %} - {{ comment.editform.content(class="jsoff-show edit") }} - {% endif %} -
-
-
- - {{ render_comment(comment2, comment2.editform) }} -
- -{% endblock %} \ No newline at end of file diff --git a/yadc/templates/user/profile.html b/yadc/templates/user/profile.html index a1f98ae..a92ece5 100644 --- a/yadc/templates/user/profile.html +++ b/yadc/templates/user/profile.html @@ -1,11 +1,6 @@ {% extends 'layout/base.html' %} {% from '_includes.html' import render_comment with context %} -{#{% block sidebar %} -{{ super()}} - -{% endblock %}#} - {% block content %}

{{ user.username }}