diff --git a/SQL/site_data.sql b/SQL/site_data.sql index fc2e26f..5e4e972 100644 --- a/SQL/site_data.sql +++ b/SQL/site_data.sql @@ -318,7 +318,7 @@ ALTER TABLE members_products ADD db_status INT DEFAULT 0; ALTER TABLE members_products ADD provision_status INT DEFAULT 0; ALTER TABLE members_products ADD p_file INT DEFAULT 0; ALTER TABLE members_products ADD url_status INT DEFAULT 0; - +ALTER TABLE members_products ADD product_template VARCHAR(100); -- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Personal Website','Your personal professional web presence',1,'A000001', 'banner.jpg'); -- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Professional Website','Your healthcare practice online presence ',1,'A000002', 'banner.jpg'); diff --git a/app/api/routes/routes.py b/app/api/routes/routes.py index d5d83c7..3afa4d9 100644 --- a/app/api/routes/routes.py +++ b/app/api/routes/routes.py @@ -178,8 +178,6 @@ def merms_contacts(): response = ContactService.process_request(data) return response - - @api.route("/panel/account/products", methods=["POST"]) @jwt_required() def merms_products(): diff --git a/app/api/services/account.py b/app/api/services/account.py index b92054f..17cca0b 100644 --- a/app/api/services/account.py +++ b/app/api/services/account.py @@ -345,7 +345,7 @@ class AccountService(BaseService): 'option_name': t.option_name, 'option_type': t.option_type, 'payment_uid': t.payment_uid, - 'amount': t.amount, + 'amount': round( t.amount*0.01, 2), 'status': t.status, 'added': t.added }) diff --git a/app/api/services/myproduct.py b/app/api/services/myproduct.py index f2357e4..69743bd 100644 --- a/app/api/services/myproduct.py +++ b/app/api/services/myproduct.py @@ -36,17 +36,17 @@ class MyProductsService(BaseService): validated_data = MyProductsService.validate_data(data, MyProductSetTemplateSchema()) token = validated_data.get('token') uid = validated_data.get('uid') + template_uid = validated_data.get('template_uid') member_data = Members.get_member_by_uid(uid) member_id = member_data.id - + response_data ={} product_id = validated_data.get('product_id') - template_data = [] + MembersProducts.set_member_product_template(member_id, product_id, template_uid) response_data = { "product_id": product_id, - "current_template_uid": "f7198ccc-1efc-4c40-8b79-17bc17956195", - "templates": template_data, + "new_template_uid": template_uid, "last_update": datetime.datetime.utcnow(), } @@ -82,44 +82,23 @@ class MyProductsService(BaseService): member_id = member_data.id product_id = validated_data.get('product_id') - - # class MyProductSchema(Schema): - # token = fields.Str(required=True) - # uid = fields.Str(required=True) - # product_id = fields.Str(required=True) - templates = ProductsTemplates.get_template_by_product_id(product_id) - template_data = { - 'template_16': {'title': 'Template Name-16', 'template_id': '02af24fd-2b1a-46ed-af21-87018e726408', - 'banner': 'file-icon/svg.png', 'active': '0'}, - 'template_22': {'title': 'Template Name-22', 'template_id': '8b296894-42e4-4f2e-abd1-7c2a38d6e07b', - 'banner': 'file-icon/svg.png', 'active': '0'}, - 'template_47': {'title': 'Template Name-47', 'template_id': 'ef2ffa1c-9272-42cd-9d33-0e614047b4f8', - 'banner': 'file-icon/svg.png', 'active': '0'}, - 'template_25': {'title': 'Template Name-25', 'template_id': 'b3a7ba31-dc47-4a40-a5cc-fd1ff27d6b78', - 'banner': 'file-icon/svg.png', 'active': '1'}, - 'template_49': {'title': 'Template Name-49', 'template_id': '60959c69-6672-4f69-a006-eeb7d210e605', - 'banner': 'file-icon/svg.png', 'active': '0'}, - 'template_27': {'title': 'Template Name-27', 'template_id': 'e4acb98a-c584-45f2-bece-af677dcf0a1f', - 'banner': 'file-icon/svg.png', 'active': '0'}, - 'template_51': {'title': 'Template Name-51', 'template_id': '975ee42e-3169-4978-92d7-d28e7e2ac014', - 'banner': 'file-icon/svg.png', 'active': '0'}, - 'template_9': {'title': 'Template Name-9', 'template_id': 'fc8f0738-6500-4775-9895-2047cd275302', - 'banner': 'file-icon/svg.png', 'active': '0'}, - } template_data = [] - for t in templates: - template_data.append({ - 'id': t.id, - 'template_uid': t.uid, - 'title': t.name, - 'active': 1, - 'banner': 'https://qa-panel.mermsemr.com/static/media/', - 'added': t.added.isoformat() if t.added else None - }) + memberSubscription = MembersProducts.get_member_product_by_product_member_id(member_id, product_id) + if memberSubscription: + templates = ProductsTemplates.get_template_by_product_id(product_id) + for t in templates: + template_data.append({ + 'id': t.id, + 'template_uid': t.uid, + 'title': t.name, + 'active': 1, + 'banner': 'https://qa-panel.mermsemr.com/static/media/', + 'added': t.added.isoformat() if t.added else None + }) response_data = { "product_id": product_id, - "current_template_uid": "f7198ccc-1efc-4c40-8b79-17bc17956195", + "current_template_uid": memberSubscription.product_template if memberSubscription else None , "templates": template_data, "last_update": datetime.datetime.utcnow(), } diff --git a/app/models/members_products.py b/app/models/members_products.py index e5ff613..f0dbb12 100644 --- a/app/models/members_products.py +++ b/app/models/members_products.py @@ -30,6 +30,7 @@ class MembersProducts(db.Model): status = db.Column(db.Integer, nullable=True, default=0) added = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated = db.Column(db.DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) + product_template= db.Column(db.String(100), nullable=True) # name = db.Column(db.String(100), nullable=False) # description = db.Column(db.String(250), nullable=False) @@ -69,6 +70,14 @@ class MembersProducts(db.Model): return None return member_product + @classmethod + def set_member_product_template(cls, member_id, product_id, product_template): + member_product = cls.query.filter_by(member_id=str(member_id), product_id=str(product_id)).first() + if not member_product: + return None + member_product.product_template = product_template + return product_template + @classmethod def create_subscription(cls, member_id ,product_id,status,internal_url): @@ -144,6 +153,7 @@ class MembersProducts(db.Model): 'dns_group': self.dns_group, 'status': self.status, 'added': self.added, + 'product_template': self.product_template, 'updated': self.updated }