Exemplo n.º 1
0
Arquivo: main.py Projeto: phares/leave
    def post(self):
        #New employee
        newemployee = self.request.get('newemployee')
        firstname = self.request.get('firstname')
        lastname = self.request.get('lastname')
        idno = self.request.get('idno')
        phone = self.request.get('phone')
        hiredate = self.request.get('hiredate')
        #email = self.request.get('email')
        job = self.request.get('job')
        type = self.request.get('type')

        #New job title
        newjob = self.request.get('newjob')
        title = self.request.get('title')
        description = self.request.get('description')

        #New leave type
        newleavetype = self.request.get('newleavetype')
        leavetype = self.request.get('leavetype')
        leaveduration = self.request.get('leaveduration')
        leavedescription = self.request.get('leavedescription')

        if newemployee == 'true':
            employee = EmployeeDB(

                    firstname = str(firstname),
                    lastname = str(lastname),
                    idno = int(idno),
                    phone = str(phone),
                    hiredate = str(hiredate),
                    email = str(users.get_current_user().email()),
                    job = str(job),
                    type = str(type),
                    privilege = 'admin'
            )

            employee.put()

            self.redirect('/hr')

        if newjob == 'true':
            job = JobDB(
                title = str(title),
                description = str(description)
            )
            job.put()

            self.redirect('/?activity=job')

        if newleavetype == 'true':
            type = LeaveTypeDB(
                type = str(leavetype),
                duration = int(leaveduration),
                description = str(leavedescription)
            )
            type.put()

            self.redirect('/?activity=leave')
Exemplo n.º 2
0
Arquivo: main.py Projeto: phares/leave
    def post(self):

        user = str(users.get_current_user().email())
        thisuser =EmployeeDB.query(EmployeeDB.email==user,EmployeeDB.privilege=='admin').get()

        #Approve
        approve = (self.request.get('approve'))
        decline = (self.request.get('decline'))

        #New employee
        newemployee = self.request.get('newemployee')
        firstname = self.request.get('firstname')
        lastname = self.request.get('lastname')
        idno = self.request.get('idno')
        phone = self.request.get('phone')
        hiredate = self.request.get('hiredate')
        email = self.request.get('email')
        job = self.request.get('job')
        type = self.request.get('type')
        privilege = self.request.get('privilege')

        #New job title
        newjob = self.request.get('newjob')
        title = self.request.get('title')
        description = self.request.get('description')

        #New holiday
        newholiday = self.request.get('newholiday')
        dth = self.request.get('holidate')
        kind = self.request.get('kind')
        name = self.request.get('name')

        #New leave type
        newleavetype = self.request.get('newleavetype')
        leavetype = self.request.get('leavetype')
        leaveduration = self.request.get('leaveduration')
        leavedescription = self.request.get('leavedescription')

        if newholiday == 'true':
            dateholi = datetime.datetime.strptime(dth,'%Y-%m-%d')
            holiday = HoliDayDB(
                date = dateholi,
                name = str(name),
                kind = str(kind)
            )
            holiday.put()
            self.redirect('/hr?hractivity=holiday')

        if newemployee == 'true':
            employee = EmployeeDB(

                    firstname = str(firstname),
                    lastname = str(lastname),
                    idno = int(idno),
                    phone = str(phone),
                    hiredate = str(hiredate),
                    email = str(email),
                    job = str(job),
                    type = str(type),
                    privilege = str(privilege)
            )

            employee.put()
            self.redirect('/hr?hractivity=employee')

        if newjob == 'true':
            job = JobDB(
                title = str(title),
                description = str(description)
            )
            job.put()
            self.redirect('/hr?hractivity=job')

        if newleavetype == 'true':
            type = LeaveTypeDB(
                type = str(leavetype),
                duration = int(leaveduration),
                description = str(leavedescription)
            )
            type.put()
            self.redirect('/hr?hractivity=leave')

        if approve or decline !=''  :
            st = 'error!'

            if approve !='':
                st = 'Approved'
            if decline !='':
                st = 'Declined'
            if st == 'Approved':
                x = LeaveDB.get_by_id(int(approve))
            elif st == 'Declined':
                x = LeaveDB.get_by_id(int(decline))
            x.leavestatus= st
            x.approvedby = thisuser.firstname
            x.dateapproved = datetime.datetime.now().replace(tzinfo=None)
            x.put()

            aplicantmail = x.email
            user = users.get_current_user().email()
            message = mail.EmailMessage(sender="ISP leave request approval <*****@*****.**>",
                                        subject="LEAVE REQUEST APPROVAL - STATUS")

            message.to = aplicantmail
            message.body = """
                    ISPEER,

                    Your request approval status.

                    Approved by: %s
                    leavetype: %s
                    Days.: %s
                    From : %s
                    To : %s
                    Reason: %s

                    Request %s %s

                    http://leave.intellisoftplus.com/history

                    """ % (thisuser.firstname,x.leavetype,x.days,x.datefrom.strftime('%d-%B-%Y'),x.dateto.strftime('%d-%B-%Y'),x.reason,st,x.dateapproved)

            message.send()
            self.redirect('/hr')