URL name
This commit is contained in:
@@ -67,6 +67,7 @@ ALTER TABLE ONLY members_profile
|
|||||||
|
|
||||||
ALTER TABLE members_profile OWNER TO merms_panel
|
ALTER TABLE members_profile OWNER TO merms_panel
|
||||||
|
|
||||||
|
ALTER TABLE members_profile ADD url_name VARCHAR(25);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ class StartProfileSchema(Schema):
|
|||||||
uid = fields.Str(required=True)
|
uid = fields.Str(required=True)
|
||||||
practice =fields.Str(required=True)
|
practice =fields.Str(required=True)
|
||||||
specialization =fields.Str(required=True)
|
specialization =fields.Str(required=True)
|
||||||
introduction = fields.Str(required=True)
|
introduction = fields.Str(required=True)
|
||||||
|
url_name = fields.Str(required=True)
|
||||||
|
|||||||
@@ -220,6 +220,18 @@ class AccountService(BaseService):
|
|||||||
practice = str(validated_data.get('practice'))
|
practice = str(validated_data.get('practice'))
|
||||||
specialization = str(validated_data.get('specialization'))
|
specialization = str(validated_data.get('specialization'))
|
||||||
introduction = str(validated_data.get('introduction'))
|
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_uid = ''
|
||||||
profile_completed = None
|
profile_completed = None
|
||||||
member = Members.get_member_by_uid(uid)
|
member = Members.get_member_by_uid(uid)
|
||||||
@@ -242,7 +254,7 @@ class AccountService(BaseService):
|
|||||||
profile_completed = member.profile_completed
|
profile_completed = member.profile_completed
|
||||||
else:
|
else:
|
||||||
profle_result = MembersProfile.create_member_profile(member.id, practice, specialization,
|
profle_result = MembersProfile.create_member_profile(member.id, practice, specialization,
|
||||||
introduction)
|
introduction,url_name)
|
||||||
if profle_result:
|
if profle_result:
|
||||||
profile_uid = profle_result.uid
|
profile_uid = profle_result.uid
|
||||||
if profile_uid is not None and profile_uid != '':
|
if profile_uid is not None and profile_uid != '':
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class MembersProfile(db.Model):
|
|||||||
practice = db.Column(db.String(100), nullable=False)
|
practice = db.Column(db.String(100), nullable=False)
|
||||||
specialization = db.Column(db.String(100), nullable=False)
|
specialization = db.Column(db.String(100), nullable=False)
|
||||||
introduction = db.Column(db.String(3500), nullable=True)
|
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())
|
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())
|
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 None
|
||||||
return member_profile
|
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
|
@classmethod
|
||||||
def get_member_product_by_product_member_id(cls, member_id, product_id):
|
def get_member_product_by_product_member_id(cls, member_id, product_id):
|
||||||
@@ -53,7 +61,7 @@ class MembersProfile(db.Model):
|
|||||||
|
|
||||||
|
|
||||||
@classmethod
|
@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
|
# Create the subscription
|
||||||
'''
|
'''
|
||||||
merms_panel=# select * from members_profile;
|
merms_panel=# select * from members_profile;
|
||||||
@@ -69,6 +77,7 @@ class MembersProfile(db.Model):
|
|||||||
practice=practice,
|
practice=practice,
|
||||||
specialization=specialization,
|
specialization=specialization,
|
||||||
introduction=introduction,
|
introduction=introduction,
|
||||||
|
url_name = url_name,
|
||||||
added=datetime.now(timezone.utc),
|
added=datetime.now(timezone.utc),
|
||||||
updated=datetime.now(timezone.utc)
|
updated=datetime.now(timezone.utc)
|
||||||
)
|
)
|
||||||
@@ -92,6 +101,7 @@ class MembersProfile(db.Model):
|
|||||||
'practice': self.practice,
|
'practice': self.practice,
|
||||||
'specialization': self.specialization,
|
'specialization': self.specialization,
|
||||||
'introduction': self.dns_group,
|
'introduction': self.dns_group,
|
||||||
|
'url_name': self.url_name,
|
||||||
'added': self.added,
|
'added': self.added,
|
||||||
'updated': self.updated
|
'updated': self.updated
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user