Skip to content

Commit

Permalink
Merge pull request #56 from cf15-t5/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
lutfianRhdn authored Aug 25, 2023
2 parents 3cc2c50 + 435bf99 commit 83c8743
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/repositories/UserRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@


class UserRepository:

def getAllUser(self):
return User.query.all()

def getUserByRole(self,role):
return User.query.filter_by(role=role).all()

def getUserByEmail(self, email):
return User.query.filter_by(email=email).first()

Expand Down Expand Up @@ -60,3 +63,4 @@ def updateBalance(self, id, nominal, operator):

db.session.commit()
return user

7 changes: 4 additions & 3 deletions src/services/AuthService.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def failedOrSuccessRequest(status, code, data):
"code": code,
'data': data,
}
def _sendNotification(self,data):
def _sendNotification(self,data,to):
templates = render_template(
'html/registeredEoNotification.html',
name=data.name,
Expand All @@ -25,7 +25,7 @@ def _sendNotification(self,data):
sendMail(
templates=templates,
subject="Ticket Event",
to=data.email
to=to
)
return True

Expand All @@ -40,7 +40,8 @@ def registerUser(self, data):
return self.failedOrSuccessRequest('failed', 400, 'Validation failed')
newUser = user_repository.createNewUser(data)
if(newUser.role == 'EVENT_ORGANIZER'):
self._sendNotification(newUser)
userAdmin = user_repository.getUserByRole('ADMIN')
self._sendNotification(newUser,userAdmin[0].email)

return self.failedOrSuccessRequest('success', 201, queryResultToDict([newUser])[0])
except ValueError as e:
Expand Down

0 comments on commit 83c8743

Please sign in to comment.