diff --git a/data/__all_models.py b/data/__all_models.py index d36c8c6..8ad14ce 100644 --- a/data/__all_models.py +++ b/data/__all_models.py @@ -1 +1 @@ -from . import users, roles, files +from . import users, roles, files, projects, staff_projects diff --git a/data/projects.py b/data/projects.py new file mode 100644 index 0000000..7a41ded --- /dev/null +++ b/data/projects.py @@ -0,0 +1,19 @@ +import sqlalchemy +from flask_login import UserMixin +from datetime import date + +from .db_session import SqlAlchemyBase + + +class Projects(SqlAlchemyBase, UserMixin): + __tablename__ = 'projects' + + id = sqlalchemy.Column(sqlalchemy.Integer, + primary_key=True, autoincrement=True) + name = sqlalchemy.Column(sqlalchemy.String, nullable=False) + about = sqlalchemy.Column(sqlalchemy.String, nullable=True) + photo = sqlalchemy.Column(sqlalchemy.Text) + date_create = sqlalchemy.Column(sqlalchemy.Date, + default=date.today()) + creator = sqlalchemy.Column(sqlalchemy.Integer, + sqlalchemy.ForeignKey("users.id"), nullable=True, default=None) diff --git a/data/staff_projects.py b/data/staff_projects.py new file mode 100644 index 0000000..0193517 --- /dev/null +++ b/data/staff_projects.py @@ -0,0 +1,16 @@ +import sqlalchemy +from flask_login import UserMixin + +from .db_session import SqlAlchemyBase + + +class StaffProjects(SqlAlchemyBase, UserMixin): + __tablename__ = 'staff_projects' + + id = sqlalchemy.Column(sqlalchemy.Integer, + primary_key=True, autoincrement=True) + user = sqlalchemy.Column(sqlalchemy.Integer, + sqlalchemy.ForeignKey("users.id"), nullable=True, default=None) + role = sqlalchemy.Column(sqlalchemy.Text) + permission = sqlalchemy.Column(sqlalchemy.Integer, + sqlalchemy.ForeignKey("roles.id"), nullable=True, default=None) \ No newline at end of file diff --git a/functions.py b/functions.py index d28d749..7c4cdca 100644 --- a/functions.py +++ b/functions.py @@ -1,5 +1,7 @@ import smtplib from email.message import EmailMessage +from data.roles import Roles +from data import db_session def check_password(password=''): @@ -35,3 +37,16 @@ def mail(msg, to, topic='Подтверждение почты'): mailServer.ehlo() mailServer.send_message(em) mailServer.quit() + + +def init_db_default(): + data_session = db_session.create_session() + roles = [['admin', 2], ['moderator', 1], ['user', 0]] + for i in roles: + role = Roles( + name=i[0], + rights=i[1] + ) + data_session.add(role) + data_session.commit() + data_session.close() diff --git a/main.py b/main.py index 25e2b95..74638ab 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ from werkzeug.datastructures import CombinedMultiDict from werkzeug.utils import redirect from itsdangerous import URLSafeTimedSerializer, SignatureExpired -from functions import check_password, mail +from functions import check_password, mail, init_db_default from forms.edit_profile import EditProfileForm from forms.login import LoginForm from forms.register import RegisterForm @@ -32,9 +32,11 @@ def base(): return redirect('/projects') -@app.route('/projects') +@app.route('/projects', methods=['GET', 'POST']) def project(): if current_user.is_authenticated: + if request.method == 'POST': + print(request.form.to_dict()) return render_template('projects.html', title='Проекты') else: return redirect('/login') @@ -190,8 +192,17 @@ def confirmation(token): return redirect('/login?message=Срок действия ссылки истек, данные удалены&danger=True') +@app.errorhandler(404) +def page_not_found(error): + return render_template('page404.html', title='Страница не найдена') + + def main(): - db_session.global_init("db/incepted.db") + db_path = 'db/incepted.db' + db = os.path.exists(db_path) + db_session.global_init(db_path) + if not db: + init_db_default() serve(app, host='0.0.0.0', port=5000) diff --git a/static/css/page404.css b/static/css/page404.css new file mode 100644 index 0000000..8f618ad --- /dev/null +++ b/static/css/page404.css @@ -0,0 +1,72 @@ +.navbar { + display: none !important; +} +.page_404 { + height: 55vw; + background-color: #dcb495; + display: flex; + flex-direction: column; +} +.header_block { + display: flex; + flex-direction: column; + width: 80%; + height: 15vw; + margin-left: 10%; + margin-top: 80px; + justify-content: space-around; +} +.header { + display: flex; + align-items: center; + justify-content: center; +} +.line_top { + height: 0.03vw; + background: #000000; + width: 32vw; +} +.header_rect { + width: 15vw; + height: 3.3vw; + background-color: #000000; + display: flex; + justify-content: center; + align-items: center; +} +.header_rect_text { + color: #ffffff; + font-size: 1.6vw; +} +.header_title { + color: #000000; + font-size: 3vw; +} +.line_bottom { + height: 0.03vw; + background: #000000; + width: 100%; +} +.link_block { + width: 100%; + margin-top: 50px; + display: flex; + justify-content: center; +} +.block_to_home { + width: 20vw; + height: 20vw; + background-color: #000000; + display: flex; + justify-content: center; + align-items: center; + border-radius: 10vw; +} +.link_to_home { + height: 12.3vw; + width: 15vw; +} +.link_image { + height: 12.3vw; + width: 15vw; +} \ No newline at end of file diff --git a/static/css/profile.css b/static/css/profile.css index 05f6d15..33c4d18 100644 --- a/static/css/profile.css +++ b/static/css/profile.css @@ -6,7 +6,7 @@ background: linear-gradient( rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8) ), url(../images/back_profile_one.jpg);background-repeat: repeat; background-position: center; } .profile_block { - height: 65vw; + height: 57vw; width: 85%; margin-left: 7.5%; margin-bottom: 6%; diff --git a/static/css/projects.css b/static/css/projects.css index 31fb06c..59aa669 100644 --- a/static/css/projects.css +++ b/static/css/projects.css @@ -1,3 +1,67 @@ .projects_page { - height: 65vw; + height: 120vw; + background-color: #dcb495; +} +.header_block { + width: 100%; + height: 50vw; + background-position: center; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + background: linear-gradient( rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.85) ), url(../images/back_project_one.jpg);background-repeat: repeat; background-position: center; +} +.header_title { + color: #ffffff; + font-size: 7vw; +} +.header_title_2 { + color: #ffffff; + text-align: center; + margin-top: 50px; + font-size: 1.5vw; + width: 50vw; +} +.find_block { + width: 100%; + height: 15vw; + background-color: #dcb495; + display: flex; + align-items: center; + flex-direction: row; + justify-content: center; +} +.find_input_text { + margin-right: 12px; + background-color: #EDCBB0; + border: #EDCBB0; + width: 45vw; + height: 5vw; + color: #776658; + border-radius: 30px; + vertical-align: middle; +} +.find_input_button { + margin-left: 12px; + background-color: #9E795A; + border: #9E795A; + width: 10vw; + height: 5vw; + color: #ffffff; + border-radius: 30px; + vertical-align: middle; +} +.list_project_block { + margin-left: 3%; + border: 2px solid #694a2d; + border-radius: 25px; + width: 94%; + height: 45vw; +} +.list_project { + width: 95%; + margin-left: 2.5%; + height: 95%; + margin-top: 2.5%; } \ No newline at end of file diff --git a/static/images/back_project_one.jpg b/static/images/back_project_one.jpg new file mode 100644 index 0000000..0619403 Binary files /dev/null and b/static/images/back_project_one.jpg differ diff --git a/templates/page404.html b/templates/page404.html new file mode 100644 index 0000000..1929df3 --- /dev/null +++ b/templates/page404.html @@ -0,0 +1,27 @@ + +{% extends "base.html" %} {% block content %} +
+
+
+
+
+ Ошибка 404 +
+
+
+
+

Страница не найдена

+
+
+
+
+
+ +
+{% endblock %} \ No newline at end of file diff --git a/templates/profile.html b/templates/profile.html index b914ecd..643ff7f 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -10,6 +10,11 @@ Редикторовать + +
+

Выйти

+
+
@@ -88,11 +93,6 @@
{{ form.submit(type="submit", class="profile_button") }} - -
-

Выйти

-
-
diff --git a/templates/projects.html b/templates/projects.html index e93cc60..b0d3fd8 100644 --- a/templates/projects.html +++ b/templates/projects.html @@ -1,6 +1,40 @@ {% extends "base.html" %} {% block content %}
- +
+

КНИЖКИ

+ Здесь вы можете создавать свои проекты, изменять их, ставить дату дедлайна и + добавлять участников в своей проект. +
+
+
+ + +
+
+
+
+
+

+ +

+
+
+ This is the first item's accordion body. It is shown by default, until the + collapse plugin adds the appropriate classes that we use to style each element. These classes + control the overall appearance, as well as the showing and hiding via CSS transitions. You can + modify any of this with custom CSS or overriding our default variables. It's also worth noting + that just about any HTML can go within the .accordion-body, though the transition + does limit overflow. +
+
+
+
+
{% endblock %} \ No newline at end of file