Skip to content

Commit

Permalink
lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
RustamovAkrom committed Oct 29, 2024
1 parent 5e6b9be commit 90a2617
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
21 changes: 6 additions & 15 deletions app/admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
from flask_admin.form import FileUploadField, SecureForm
from flask_login import current_user

from wtforms import StringField
from wtforms.validators import DataRequired

from app.config import config


Expand All @@ -17,15 +14,15 @@ class BaseAdminModelView(ModelView):
can_delete = True

column_display_pk = True
column_exclude_list = ['created_at', 'updated_at']
form_excluded_columns = ['created_at', 'updated_at']
column_exclude_list = ["created_at", "updated_at"]
form_excluded_columns = ["created_at", "updated_at"]

def __init__(self, model, session, **kwargs):
super().__init__(model, session, **kwargs)

def on_model_change(self, form, model, is_created):
return super().on_model_change(form, model, is_created)

def is_accessible(self):
return current_user.is_authenticated and current_user.is_admin

Expand Down Expand Up @@ -66,15 +63,11 @@ class ProjectView(BaseAdminModelView):
"img": FileUploadField("Image", base_path=config.UPLOAD_FOLDER)
}
form_columns = ["name", "img", "description", "created", "url", "category"]
form_ajax_refs = {
"category": {
"fields": ['name'],
'page_size': 10
}
}
form_ajax_refs = {"category": {"fields": ["name"], "page_size": 10}}


class CategoryView(BaseAdminModelView):
form_columns = ['name']
form_columns = ["name"]


class SocialView(BaseAdminModelView):
Expand All @@ -95,5 +88,3 @@ class ContactView(BaseAdminModelView):

class UserView(BaseAdminModelView):
pass


21 changes: 15 additions & 6 deletions app/routes/site.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import random
import os

from flask import Blueprint, render_template, abort, send_from_directory, flash, url_for, redirect, request
from flask import (
Blueprint,
render_template,
abort,
send_from_directory,
flash,
url_for,
redirect,
request,
)
from flask_mail import Message
from app.models import Resume, About, Skill, Service, Project, Category, Contact
from app.extensions import db, mail
Expand All @@ -19,16 +28,16 @@ def uploaded_file(filename):
return send_from_directory(config.UPLOAD_FOLDER, filename)


@dp.route('/upload', methods=['POST'])
@dp.route("/upload", methods=["POST"])
def uplod_file():
if 'file' not in request.files:
if "file" not in request.files:
return "No File part", 400
file = request.files['file']
if file.filename == '':
file = request.files["file"]
if file.filename == "":
return "No selected file", 400
file.save(os.path.join(config.UPLOAD_FOLDER, file.filename))

file_url = url_for('site.uploaded_file', filename=file.filename)
file_url = url_for("site.uploaded_file", filename=file.filename)
return redirect(file_url)


Expand Down

0 comments on commit 90a2617

Please sign in to comment.