def get(self, name): user = self.request.environ['current_user'] name = urllib.unquote(name).decode('utf-8') prs = PerformanceReview.all().filter('manager', user).order("-date").fetch(1000) def get_sub_prs(manager, prs): current_manager_prs = PerformanceReview.all().filter('manager', manager).order("-date").fetch(1000) prs.extend(current_manager_prs) for manager in manager.subs: get_sub_prs(manager, prs) return prs if user.edit_sub_reviews: prs = [] get_sub_prs(user, prs) if name == 'all': departments = Dept.all().fetch(1000) else: departments = Dept.all().filter('name', name).fetch(1000) for department in departments: department.prs = filter(lambda x: x.employee.dept.name == department.name and x.period.is_open, prs) template_values = {'name': name, 'depts': departments, 'current_user': user.email} path = 'templates/api.manager.departments.html' self.response.out.write(template.render(path, template_values))
def get(self, key): login_url = users.create_login_url(self.request.uri) logout_url = users.create_logout_url(login_url) user = self.request.environ['current_user'] emp = Model.get(key) pr = PerformanceReview.all().filter('employee', emp).\ order('-date').get() pr_form = pr.forms.filter('type', self.type).get() if pr_form is None: pr_form = PerformanceReviewForm(pr=pr, type=self.type, status='draft') pr_form.put() self.form = pr_form if self.flag: job_assessment = JobAssessment(form=pr_form) job_assessment.put() if self.flag: self.redirect('/%(type)s/pr/get/%(type)s/%(key)s' % {'type': self.type, 'key': pr.key()})
def get_sub_prs(manager, prs): current_manager_prs = PerformanceReview.all().filter('manager', manager).order("-date").fetch(1000) prs.extend(current_manager_prs) for manager in manager.subs: get_sub_prs(manager, prs) return prs
def get_prev_pr(pr): prev_pr = PerformanceReview.all().order('-date').\ filter('date <', pr.date).\ filter('employee', pr.employee).get() return prev_pr
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))
def get(self): today = datetime.date.today() subject = 'Performance Review' month = datetime.timedelta(days=30) week = datetime.timedelta(days=7) day = datetime.timedelta(days=1) prs = PerformanceReview.all().filter('start_date >=', today) for pr in prs: delta = pr.date - today text = 'Your Performance Review starts in ' \ + str(delta.days) + ' days' if delta == month or delta == week or delta == day: send_message(pr.employee.email, subject, text)
def get(self, key): user = self.request.environ['current_user'] login_url = users.create_login_url(self.request.uri) logout_url = users.create_logout_url(login_url) try: pr = PerformanceReview.get(key) except: try: form = PerformanceReviewForm.get(key) pr = form.pr except: self.error(405) return if not pr.is_open and self.type == 'employee': self.type = 'manager' self.path = 'templates/api.employee_maf.html' form = pr.forms.filter('type', self.type).get() prev_pr = PerformanceReview.all().order('-date').\ filter('date <', pr.date).\ filter('employee', pr.employee).get() if prev_pr is not None: prev_form = prev_pr.forms.filter('type', 'manager').get() else: prev_form = None upload_url = blobstore.create_upload_url('/upload') upload_form_url = blobstore.create_upload_url('/upload_xml') self.template_values.update({'form': form, 'file_key': form.file_key, 'user': user, # 'upload_form_url': upload_form_url, 'upload_url': upload_url, 'prev_form': prev_form, 'file_name': form.file_name})
def get(self, key): period = PerformanceReviewPeriod.get(key) prs = PerformanceReview.all().filter('period', period).fetch(1000) prs = sorted(prs, key=lambda x: x.employee.dept.name) for pr in prs: if get_prev_pr(pr): try: if get_prev_pr(pr).manager_form.get_all_data['salary'].\ value != pr.manager_form.get_all_data['salary'].value: pr.salary_highlight = 'highlight' if get_prev_pr(pr).manager_form.get_all_data['grade'].\ value != pr.manager_form.get_all_data['grade'].value: pr.grade_highlight = 'highlight' except AttributeError: pr.grade_highlight = None path = 'templates/detailed_report.html' self.response.out.write(template.render(path, {'prs': prs}))
def get(self, name): user = self.request.environ['current_user'] name = urllib.unquote(name).decode('utf-8') prs = PerformanceReview.all().filter('manager', user).order("-date").fetch(1000) def get_sub_prs(manager, prs): current_manager_prs = PerformanceReview.all().filter('manager', manager).order("-date").fetch(1000) prs.extend(current_manager_prs) for manager in manager.subs: get_sub_prs(manager, prs) return prs if user.edit_sub_reviews: prs = [] get_sub_prs(user, prs) periods = PerformanceReviewPeriod.all().filter('description', name).fetch(1000) for period in periods: period.prs = filter(lambda x: x.period.key() == period.key(), prs) template_values = {'name': name, 'periods': periods, 'current_user': user.email} path = 'templates/api.manager.periods.html' self.response.out.write(template.render(path, template_values))