Beispiel #1
0
    def get(self):

        user = self.request.environ['current_user']

        prs = PerformanceReview.gql("WHERE employee = :user ORDER BY date DESC", user = user)
        prs = prs.fetch(1000)

        user_is_manager = 0
        for role in user.role:
            if Role.get(role).value == "manager":
                user_is_manager = 1
                break

        current_pr = None

        comments = None

        if not user_is_manager:
            comments = CommentToForm.gql("WHERE manager = :manager AND comment = NULL", manager = user).fetch(1000)
            comments = filter(lambda x: x.pr.period.is_open, comments)
        if prs:
            if prs[0].period.is_open:
                current_pr = prs[0]
                prs.remove(prs[0])

        template_values = {'current_pr': current_pr,
                           'prs': prs,
                           'user': user,
                           'comments': comments
                        }

        path = 'templates/api.employee.html'
        self.response.out.write(template.render(path, template_values))
Beispiel #2
0
    def get(self):
        manager = self.request.environ['current_user']

        user_departments_keys = []

        prs = PerformanceReview.all().filter('manager',
                                             manager)

        for pr in prs:
            if pr.period.is_open:
                if not pr.employee.dept.key() in user_departments_keys:
                    user_departments_keys.append(pr.employee.dept.key())

        user_departments = map(lambda x: Dept.get(x), user_departments_keys)

        archived_periods = PerformanceReviewPeriod.gql("WHERE is_open = false ORDER BY start_date DESC").fetch(1000)

        def manager_has_pr_in_period(period):
            for pr in period.performance_reviews:
                if pr.manager.email == manager.email:
                    return True

        archived_periods = filter(manager_has_pr_in_period, archived_periods)

        comments = CommentToForm.gql("WHERE manager = :manager", manager = manager).fetch(1000)
        comments = filter(lambda x: x.pr.period.is_open, comments)

        template_values = {"departments": user_departments,
                           "archived_periods": archived_periods,
                           "comments": comments
                           }

        path = 'templates/api.manager.home.html'
        self.response.out.write(template.render(path, template_values))
Beispiel #3
0
    def post(self):

        manager_email = self.request.get('manager_email')
        pr_key = self.request.get('pr_key')

        manager = User.gql("WHERE email = :manager_email", manager_email = manager_email).get()
        pr = PerformanceReview.get(pr_key)

        if manager is None:
            self.response.out.write('Some error happened. Try again please')
            return

        comment_to_form = CommentToForm.gql("WHERE pr = :pr AND manager = :manager", pr = pr, manager = manager).get()

        if comment_to_form is None:
            comment_to_form = CommentToForm(manager = manager,
                                        pr = pr)
            comment_to_form.put()

            self.response.out.write('You have successfully requested comment form %s %s' %(manager.first_name, manager.last_name))
        else:
            self.response.out.write('You have already requested comment form %s %s' %(manager.first_name, manager.last_name))