def do_notify(self, expertid): projectid = self.table.kwargs['projectid'] project_dict = project_db_handle.GetProjectInstanceById( projectid, returnDict=True) expert_db_handle.notify_expert( expertid, sendmessages.TEMPLATE_NOTIFY_REVIEW_PROJECT, project_info=project_dict)
def wrapper2(self, *args, **kwargs): projectid = self.kwargs.get('projectid', None) if not projectid: raise exceptions.NotAuthorized("Missing Project ID") project = project_db_handle.GetProjectInstanceById(projectid) if not project: raise exceptions.NotAuthorized("Invalid Project ID") if not project.state in expected_states: raise exceptions.NotAuthorized("Illegal Project state") return func(self, *args, **kwargs)
def get_context_data(self, *args, **kwargs): projectid = self.kwargs['projectid'] self.submit_url = reverse(self._submit_url, args=(projectid, )) context = super(SetRuleView, self).get_context_data(**kwargs) project = project_db_handle.GetProjectInstanceById(projectid) if project.chouquyaoqiu: context['chouquyaoqiu'] = project.chouquyaoqiu else: context['chouquyaoqiu'] = u"无" return context
def get_initial(self): initial = super(CommentExpertReviewView, self).get_initial() projectid = self.kwargs['projectid'] expertid = self.kwargs['expertid'] project = project_db_handle.GetProjectInstanceById(projectid) expert = expert_db_handle.GetExpertInstanceById(expertid) initial['projectid'] = projectid initial['projectname'] = project.projectname initial['expertid'] = expertid initial['expertname'] = expert.expertname return initial
def wrapper2(self, *args, **kwargs): project = self.table.kwargs.get('project', None) if not project or not isinstance(project, Project): projectid = self.table.kwargs.get('projectid', None) if not projectid: return False project = project_db_handle.GetProjectInstanceById(projectid) self.table.kwargs['project'] = project if not project or not project.state in expected_states: return False return func(self, *args, **kwargs)
def action(self, request, projectid): experts = project_db_handle.GetNonNotifiedReviewers(projectid) project_dict = project_db_handle.GetProjectInstanceById( projectid, returnDict=True) for expert in experts: expert_db_handle.notify_expert( expert, sendmessages.TEMPLATE_NOTIFY_REVIEW_PROJECT, project_info=project_dict) project_db_handle.NotifiedReviewers(projectid, experts) return True
def FillContextByprojectid(context, projectid): project_dict = project_db_handle.GetProjectInstanceById(projectid, returnDict=True) if not project_dict: messages.error(self.request, u"无法查询到该ID(%s)的项目记录" % projectid) return for key in project_dict: if type(project_dict[key]) == date: context[key] = project_dict[key].strftime("%Y-%m-%d") elif type(project_dict[key]) == datetime: context[key] = project_dict[key].isoformat() else: context[key] = project_dict[key]
def get_initial(self): initial = expert_db_handle.get_initial_user_data(self.request.GET, default=True) projectid = self.kwargs['projectid'] project = project_db_handle.GetProjectInstanceById(projectid) experts = project_db_handle.GetBindedReviewers( project, need_reviewer_info=False) initial['id'] = projectid chouqurenshu = (project.chouqurenshu - len(experts)) if chouqurenshu < 1: chouqurenshu = 1 initial['chouqurenshu'] = chouqurenshu return initial
def get_initial(self): initial = super(RandomBindView, self).get_initial() projectid = self.kwargs['projectid'] project = project_db_handle.GetProjectInstanceById(projectid) experts = project_db_handle.GetBindedReviewers( project, need_reviewer_info=False) initial['id'] = project.id initial['projectname'] = project.projectname self.modal_header = self._modal_header % project.projectname chouqurenshu = (project.chouqurenshu - len(experts)) if chouqurenshu < 1: chouqurenshu = 1 initial['chouqurenshu'] = chouqurenshu return initial
def wrapper2(self, request, data, *args, **kwargs): projectid = data.get('id') or data.get('projectid') if not projectid: messages.error(request, u"项目状态错误,请刷新后重新提交") return False project = project_db_handle.GetProjectInstanceById(projectid) if not project: messages.error(request, u"项目状态错误,请刷新后重新提交") return False if not project.state in expected_states: messages.error(request, u"项目状态错误,请刷新后重新提交") return False if 'id' in data: data['id'] = project elif 'projectid' in data: data['projectid'] = project return func(self, request, data, *args, **kwargs)
def get_matchcandidate2_data(self): user_data = expert_db_handle.get_initial_user_data(self.request.GET, default=False) if not user_data: return [] projectid = self.kwargs['projectid'] project = project_db_handle.GetProjectInstanceById(projectid) excluders = [{ 'var': 'suozaidaiwei', 'operator': 'exact', 'words': project.shenbaodanwei }] filters = [] _filters = {'state': 'approved'} expert_db_handle.dict2filter(filters, _filters) return expertmgmt_views.get_experts_data(user_data, filters=filters, excluders=excluders)
def get_initial(self): initial = super(ViewReviewResultView, self).get_initial() projectid = self.kwargs['projectid'] expertid = self.kwargs['expertid'] project = project_db_handle.GetProjectInstanceById(projectid) expert = expert_db_handle.GetExpertInstanceById(expertid) initial['projectid'] = projectid initial['projectname'] = project.projectname initial['expertid'] = expertid initial['expertname'] = expert.expertname reviewer = project_db_handle.GetReviewerInstanceById( project, expertid, project_expected_states=['start_review', 'finished'], reviewer_expected_states=[REVIEWER_SELECTED]) initial['comments'] = reviewer.comments initial['comments_attachments'] = reviewer.comments_attachments initial['comments_on_comments'] = reviewer.comments_on_comments return initial
def get_initial(self): redirect = reverse("horizon:settings:user:index") initial = super(FillReviewContentView, self).get_initial() projectid = self.kwargs['projectid'] expertid = expert_db_handle.get_expertid_from_keystone_user( self.request, redirect=redirect) try: project = project_db_handle.GetProjectInstanceById(projectid) reviewer = project_db_handle.GetReviewerInstanceById( project, expertid, project_expected_states=['start_review', 'finished']) except Exception as e: exceptions.handle(self.request, e.message, redirect=redirect) initial['projectid'] = projectid initial['id'] = reviewer.id initial['comments'] = reviewer.comments initial['comments_attachments'] = reviewer.comments_attachments if project.projectname: self.modal_header = self._modal_header % project.projectname else: self.modal_header = self._modal_header % u'-' return initial
def get_project(self): projectid = self.kwargs['projectid'] return project_db_handle.GetProjectInstanceById(projectid)
def get_context_data(self, *args, **kwargs): context = super(SearchCandidate2View, self).get_context_data(**kwargs) projectid = self.kwargs['projectid'] project = project_db_handle.GetProjectInstanceById(projectid) context['chouquyaoqiu'] = project.chouquyaoqiu return context