From 73a5820535eafc800113b42301b40f75d8e5ce8e Mon Sep 17 00:00:00 2001 From: Mustafa Yontar Date: Fri, 12 Feb 2021 21:12:17 +0300 Subject: [PATCH] docker compose run with .env file docker compose volumes fix import fix add methods and indexes for models --- docker-compose-dev.yaml | 25 ++++++++++++------------- main.py | 1 - models/Account.py | 15 +++++++++++++++ models/Group.py | 36 +++++++++++++++++++++++++++++++++--- models/Payment.py | 17 +++++++++++++++++ 5 files changed, 77 insertions(+), 17 deletions(-) diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml index 3478dff..d75fc0c 100644 --- a/docker-compose-dev.yaml +++ b/docker-compose-dev.yaml @@ -3,9 +3,8 @@ version: "3" services: mongo: image: mongo - environment: - MONGO_INITDB_ROOT_USERNAME: xcoder - MONGO_INITDB_ROOT_PASSWORD: 4dun4710 + env_file: + .env volumes: - mongo_data:/data/db/ @@ -13,22 +12,22 @@ services: image: mongo-express ports: - 8081:8081 - environment: - ME_CONFIG_MONGODB_ADMINUSERNAME: xcoder - ME_CONFIG_MONGODB_ADMINPASSWORD: 4dun4710 - ME_CONFIG_OPTIONS_EDITORTHEME: ambiance - ME_CONFIG_BASICAUTH_USERNAME: xcoder - ME_CONFIG_BASICAUTH_PASSWORD: 4dun4710 + env_file: + .env + web: build: . ports: - 5000:5000 - environment: - ADUNATIO_PRIV_KEY: /code/privkey.pem - FLASK_DEBUG: 1 + env_file: + .env volumes: - .:/code volumes: - mongo_data: \ No newline at end of file + mongo_data: + driver_opts: + device: /home/john/PycharmProjects/Adunatio/mongo_data_dir/ + type: xfs + o: bind diff --git a/main.py b/main.py index 58a5def..c971179 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,6 @@ from flask_jwt_extended import JWTManager, create_access_token from mongoengine import connect from werkzeug.security import check_password_hash ,generate_password_hash -from internal_lib.AuthMethots import AuthJWT from models.Account import Account from models.Group import Group, PaymentGroup from models.Payment import Payments diff --git a/models/Account.py b/models/Account.py index 1b5966f..5f53623 100644 --- a/models/Account.py +++ b/models/Account.py @@ -1,9 +1,24 @@ from mongoengine import * from models.Union import Union +from restapi import Methods class Account(Document): + meta = { + 'index_background': True, + 'index_cls': False, + 'auto_create_index': True, + 'can_query': True, + 'with_sub_docs': True, + 'methods': [Methods.Get, Methods.List, Methods.Create], + "indexes": [ + ('bank'), + ("-bank"), + ("union"), + ('union', 'bank', "deleted") + ], + } union = ReferenceField(Union) bank = StringField() number = StringField() diff --git a/models/Group.py b/models/Group.py index c44bd2e..f27a64d 100644 --- a/models/Group.py +++ b/models/Group.py @@ -1,22 +1,52 @@ from mongoengine import * from models.Union import Union +from restapi import Methods class Group(Document): + meta = { + 'index_background': True, + 'index_cls': False, + 'auto_create_index': True, + 'can_query': True, + 'with_sub_docs': True, + 'methods': [Methods.Get, Methods.List, Methods.Create], + "indexes": [ + ('name'), + ("-name"), + ("union","deleted"), + ("union","deleted","name"), + ], + } union = ReferenceField(Union) name = StringField(required=True) - rights = ListField(StringField(),required=True) + rights = ListField(StringField(), required=True) deleted = BooleanField(default=False) + def __unicode__(self): - return "{} {}".format(self.union.name,self.name) + return "{} {}".format(self.union.name, self.name) class PaymentGroup(Document): + meta = { + 'index_background': True, + 'index_cls': False, + 'auto_create_index': True, + 'can_query': True, + 'with_sub_docs': True, + 'methods': [Methods.Get, Methods.List, Methods.Create], + "indexes": [ + ('name'), + ("-name"), + ("union"), + ('union','name',"deleted") + ], + } union = ReferenceField(Union) name = StringField(required=True) deleted = BooleanField(default=False) discount_percent = IntField(required=True) def __unicode__(self): - return "{} {}".format(self.union.name, self.name) \ No newline at end of file + return "{} {}".format(self.union.name, self.name) diff --git a/models/Payment.py b/models/Payment.py index 9409a40..39045ec 100644 --- a/models/Payment.py +++ b/models/Payment.py @@ -4,9 +4,26 @@ from models.Account import Account from models.File import File from models.Union import Union from models.User import User +from restapi import Methods class Payments(Document): + meta = { + 'index_background': True, + 'index_cls': False, + 'auto_create_index': True, + 'can_query': True, + 'with_sub_docs': True, + 'methods': [Methods.Get, Methods.List, Methods.Create], + "indexes": [ + ("union","deleted"), + ("union","deleted","account"), + ('user',"union"), + ('user',"union","deleted"), + ('union', "user","income","deleted"), + ('union', "user","deleted") + ], + } """ all payments income and outcome together! """