コード例 #1
0
class BookingController(BaseController):
    def __init__(self):
        self.dbConnection = DBOperations()

    def bookACook(self, cookBookingDetails):
        from utility.utilities import validateEmail, generateUniqueId
        from models.models import TemporaryBooking
        isRequiredInMorning = False
        isRequiredInEvening = False
        if (cookBookingDetails.get('isRequiredInMorning') == 'yes'):
            isRequiredInMorning = True
        if (cookBookingDetails.get('isRequiredInEvening') == 'yes'):
            isRequiredInEvening = True
        bookACook = TemporaryBooking(
            str(generateUniqueId()), cookBookingDetails.get('customerName'),
            cookBookingDetails.get('customerLocation'),
            cookBookingDetails.get('customerPhone'),
            cookBookingDetails.get('customerEmail'),
            cookBookingDetails.get('cookPreference'), isRequiredInMorning,
            isRequiredInEvening, cookBookingDetails.get('numberOfMembers'),
            cookBookingDetails.get('pincode'), cookBookingDetails.get('city'),
            cookBookingDetails.get('state'), cookBookingDetails.get('address'),
            cookBookingDetails.get('alternatePhoneNo'))

        return self.dbConnection.bookACook(bookACook)
コード例 #2
0
class FeedbackController(BaseController):
    def __init__(self):
        self.dbConnection = DBOperations()

    def customerFeedBack(self, feedback):

        return self.dbConnection.customerFeedback(feedback)

    #method to retreive feedback
    def getFeedbacks(self):
        response = self.dbConnection.getFeedbacks()
        feedbackList = []
        for cd in response:
            feedbackListInd = []
            for f in cd.feedback:
                if f.isApproved == True:
                    feedbackListInd.append(f.feedback)
                    feedbackListInd.reverse()
                    for fl in feedbackList:
                        if cd.id == fl.get('customerId'):
                            print cd.customerName
                            feedbackList.remove(fl)

                    feedbackList.append({
                        'customerId': cd.id,
                        'customerName': cd.customerName,
                        'latestComment': feedbackListInd[0]
                    })
        from transformer.transformers import Transformers
        return Transformers().transformGetFeedback(feedbackList,
                                                   Constants.STATUS_SUCCESS,
                                                   Constants.SUCCESS_CODE)

    #method to approve feedback
    def approveFeedback(self, approval):
        feedbackId = approval.get('feedbackId')
        return self.dbConnection.approveFeedback(feedbackId)

    #method to modify feedback
    def modifyFeedback(self, feedback, feedbackId):
        return self.dbConnection.modifyFeedback(feedback, feedbackId)
コード例 #3
0
class CareerController(BaseController):
    def __init__(self):
        self.dbConnection = DBOperations()

    def insertUserInCareers(self, userCareer):
        from utility.utilities import generateUniqueId
        from models.models import Careers
        phone = userCareer.get('phone')
        email = userCareer.get('email')
        career = Careers(str(generateUniqueId()), userCareer.get('name'),
                         email, phone, userCareer.get('role'))
        return self.dbConnection.insertUserInCareers(career)
コード例 #4
0
ファイル: controllers.py プロジェクト: SouvikDasgupta/icpi
 def subscribe(self, subscribedUser):
     from utility.utilities import validateEmail, generateUniqueId
     isEmailValidated = validateEmail(subscribedUser.get('email'))
     if (isEmailValidated):
         from models.models import SubscribedUser
         subscriptionData = SubscribedUser(str(generateUniqueId()),
                                           subscribedUser.get('email'),
                                           True)
         return DBOperations().susbscribe(subscriptionData)
     else:
         return ExceptionTransformers().transformExceptionSubcribedUser(
             Constants.INVALID_INPUT, Constants.INVALID_EMAIL,
             Constants.STATUS_FAILED)
コード例 #5
0
class ContactUsController(BaseController):
    def __init__(self):
        self.dbConnection = DBOperations()

    def insertContactUsDetails(self, contactUsDetails):
        from utility.utilities import validateEmail, validatePhoneNumber, generateUniqueId
        # isEmailValidated = validateEmail(contactUsDetails.get('email'))
        # isPhoneValidated = validatePhoneNumber(contactUsDetails.get('phone'))
        from models.models import ContactUs
        contactUsModel = ContactUs(str(generateUniqueId()),
                                   contactUsDetails.get('name'),
                                   contactUsDetails.get('email'),
                                   contactUsDetails.get('phone'))
        return self.dbConnection.insertContactUsDetails(contactUsModel)
コード例 #6
0
ファイル: controllers.py プロジェクト: SouvikDasgupta/icpi
class AdminController(BaseController):
    def __init__(self):
        self.dbConnection = DBOperations()

    def getUsers(self, userType):
        userList = []
        if userType == 'subscribers':
            from models.models import SubscribedUser
            modelList = self.dbConnection.getUsers(SubscribedUser)
            for user in modelList:
                userList.append(user.email)
            return userList

    def unsubscribeUser(self, email):
        response = self.dbConnection.unsubscribeUser(email)
        return response

    #insert cook basic details
    def addCookDetails(self, cookBasic):
        from utility.utilities import generateUniqueId, generateCompanyId
        from models.models import CookBasicDetails
        lengthOfTable = self.dbConnection.getLengthOfTable(CookBasicDetails)
        companyId = str(generateCompanyId(lengthOfTable))
        cookBasicDetails = CookBasicDetails(str(generateUniqueId()), companyId,
                                            cookBasic.get('name'),
                                            cookBasic.get('phone'),
                                            cookBasic.get('email'),
                                            cookBasic.get('joiningDate'),
                                            cookBasic.get('nativePlace'),
                                            cookBasic.get('currentPlace'),
                                            cookBasic.get('experience'),
                                            cookBasic.get('cookStatus'),
                                            cookBasic.get('leavingDate'),
                                            cookBasic.get('dob'),
                                            cookBasic.get('gender'))

        return (self.dbConnection.addCookBasicDetais(cookBasicDetails))
コード例 #7
0
class AuthenticationController(BaseController):
    def __init__(self):
        self.dbConnection = DBOperations()

    #method to register user
    def registerUser(self, userDetails):
        userType = userDetails.get('user')
        if (userType == 'admin'):
            from models.models import AdminUser
            adminUser = AdminUser(str(generateUniqueId()),
                                  userDetails.get('name'),
                                  userDetails.get('email'),
                                  userDetails.get('password'))
            return self.dbConnection.registerUser(adminUser)

    #method to verify email
    def verifyEmail(self, verifiedEmail):
        userType = verifiedEmail.get('user')
        if (userType == 'admin'):
            from models.models import AdminUser
            return self.dbConnection.verifyEmail(AdminUser,
                                                 verifiedEmail.get('id'))

    #method to login
    def login(self, loginUser):
        email = loginUser.get('email')
        password = loginUser.get('password')
        userType = loginUser.get('user')
        if userType == 'admin':
            from models.models import AdminUser
            response = self.dbConnection.login(AdminUser, email, password)
            if (response.get('notification').get('status') == 'Success'):
                jwt_encoded = jwt.encode(response,
                                         app.config['SECRET_KEY'],
                                         algorithm='HS256')
                return {'access-token': jwt_encoded}
コード例 #8
0
ファイル: controllers.py プロジェクト: SouvikDasgupta/icpi
class ContactUsController(BaseController):
    def __init__(self):
        self.dbConnection = DBOperations()

    def insertContactUsDetails(self, contactUsDetails):
        from utility.utilities import validateEmail, validatePhoneNumber, generateUniqueId
        isEmailValidated = validateEmail(contactUsDetails.get('email'))
        # isPhoneValidated = validatePhoneNumber(contactUsDetails.get('phone'))
        if isEmailValidated:
            from models.models import ContactUs
            contactUsModel = ContactUs(str(generateUniqueId()),
                                       contactUsDetails.get('name'),
                                       contactUsDetails.get('email'),
                                       contactUsDetails.get('phone'))
            return self.dbConnection.insertContactUsDetails(contactUsModel)
        else:
            return ExceptionTransformers().transformExceptionContactUs(
                Constants.INVALID_INPUT, Constants.INVALID_EMAIL,
                Constants.STATUS_FAILED)
コード例 #9
0
 def __init__(self):
     self.dbConnection = DBOperations()
コード例 #10
0
 def subscribe(self, subscribedUser):
     from utility.utilities import validateEmail, generateUniqueId
     from models.models import SubscribedUser
     subscriptionData = SubscribedUser(str(generateUniqueId()),
                                       subscribedUser.get('email'), True)
     return DBOperations().susbscribe(subscriptionData)