Skip to content

Commit

Permalink
Merge pull request #166 from DostEducation/release/sprint-8-2021
Browse files Browse the repository at this point in the history
Release - sprint 8
  • Loading branch information
Satendra-SR authored Aug 23, 2021
2 parents 10ae061 + 6a787ed commit d87c865
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/models/user_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ def get_unique(self, uuid, phone):
.first()
)

def mark_user_groups_as_inactive(self, phone):
self.filter(and_(UserGroup.user_phone == phone)).update(
{UserGroup.status: UserGroup.UserGroupStatus.INACTIVE}
)


class UserGroup(TimestampMixin, db.Model):
query_class = UserGroupQuery
__tablename__ = "user_group"

class UserGroupStatus(object):
ACTIVE = "active"
INACTIVE = "inactive"

id = db.Column(db.Integer, primary_key=True)
user_phone = db.Column(db.String(50), nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
Expand Down
5 changes: 5 additions & 0 deletions api/services/user_contact_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def init_data(self, jsonData):
def handle_contact_group(self, jsonData):
self.init_data(jsonData)
contact_groups = jsonData["contact"]["groups"]
self.mark_user_groups_as_inactive()
for group in contact_groups:
group_data = models.UserGroup.query.get_unique(
group["uuid"], self.user_phone
Expand Down Expand Up @@ -143,3 +144,7 @@ def custom_fields_contidions(self, field_name, field_value):
and field_name.startswith(self.custom_field_prefix)
else False
)

def mark_user_groups_as_inactive(self):
models.UserGroup.query.mark_user_groups_as_inactive(self.user_phone)
db.session.commit()

0 comments on commit d87c865

Please sign in to comment.