diff --git a/SQL/site_data.sql b/SQL/site_data.sql index 3f9fd34..da85439 100644 --- a/SQL/site_data.sql +++ b/SQL/site_data.sql @@ -67,6 +67,7 @@ ALTER TABLE ONLY members_profile ALTER TABLE members_profile OWNER TO merms_panel +ALTER TABLE members_profile ADD url_name VARCHAR(25); diff --git a/app/api/schemas/start_profile.py b/app/api/schemas/start_profile.py index b354c0a..d6d12c0 100644 --- a/app/api/schemas/start_profile.py +++ b/app/api/schemas/start_profile.py @@ -5,4 +5,5 @@ class StartProfileSchema(Schema): uid = fields.Str(required=True) practice =fields.Str(required=True) specialization =fields.Str(required=True) - introduction = fields.Str(required=True) \ No newline at end of file + introduction = fields.Str(required=True) + url_name = fields.Str(required=True) diff --git a/app/api/services/account.py b/app/api/services/account.py index 971320e..0429949 100644 --- a/app/api/services/account.py +++ b/app/api/services/account.py @@ -220,6 +220,18 @@ class AccountService(BaseService): practice = str(validated_data.get('practice')) specialization = str(validated_data.get('specialization')) introduction = str(validated_data.get('introduction')) + url_name = str(validated_data.get('url_name')) + + #verify is anybody is using this url name + urlNammeData = MembersProfile.get_member_product_by_url_name(url_name) + if urlNammeData: + save_error = { + "error": 'Duplicate url name', + "error_message": 'Try another url name', + "url_name": url_name, + } + return ResponseHelper.error(data=save_error) + profile_uid = '' profile_completed = None member = Members.get_member_by_uid(uid) @@ -242,7 +254,7 @@ class AccountService(BaseService): profile_completed = member.profile_completed else: profle_result = MembersProfile.create_member_profile(member.id, practice, specialization, - introduction) + introduction,url_name) if profle_result: profile_uid = profle_result.uid if profile_uid is not None and profile_uid != '': diff --git a/app/models/members_profile.py b/app/models/members_profile.py index 78644c4..7cbcd5d 100644 --- a/app/models/members_profile.py +++ b/app/models/members_profile.py @@ -26,6 +26,7 @@ class MembersProfile(db.Model): practice = db.Column(db.String(100), nullable=False) specialization = db.Column(db.String(100), nullable=False) introduction = db.Column(db.String(3500), nullable=True) + url_name = db.Column(db.String(25), nullable=True) 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()) @@ -43,6 +44,13 @@ class MembersProfile(db.Model): return None return member_profile + @classmethod + def get_member_product_by_url_name(cls, url_name): + member_product = cls.query.filter_by(url_name=str(url_name)).first() + if not member_product: + return None + return member_product + @classmethod def get_member_product_by_product_member_id(cls, member_id, product_id): @@ -53,7 +61,7 @@ class MembersProfile(db.Model): @classmethod - def create_member_profile(cls, member_id ,practice,specialization,introduction): + def create_member_profile(cls, member_id ,practice,specialization,introduction,url_name): # Create the subscription ''' merms_panel=# select * from members_profile; @@ -69,6 +77,7 @@ class MembersProfile(db.Model): practice=practice, specialization=specialization, introduction=introduction, + url_name = url_name, added=datetime.now(timezone.utc), updated=datetime.now(timezone.utc) ) @@ -92,6 +101,7 @@ class MembersProfile(db.Model): 'practice': self.practice, 'specialization': self.specialization, 'introduction': self.dns_group, + 'url_name': self.url_name, 'added': self.added, 'updated': self.updated }