Example #1
0
 def save(self, commit=True, update=False, meta_id=0):
     session = Session()
     if update:
         problem_meta = session.query(ProblemMeta).get(meta_id)
     else:
         problem_meta = ProblemMeta()
         
     problem_meta.title = self.cleaned_data['title']
     job_list = ""
     for job in self.cleaned_data['judge_flow']:
         job_list += JUDGE_FLOW_MARK_SEPARATOR + job
     problem_meta.judge_flow = job_list
     session.expire_on_commit = False
     if not update:
         session.add(problem_meta)
     session.commit()
     session.close()
     
     return problem_meta
Example #2
0
 def save(self, commit=True, meta_id=None, update=False, object_id=None):
     session = Session()
     if update:
         problem = session.query(Problem).get(int(object_id))
     else:
         problem = Problem()
     problem.problem_meta_id = meta_id
     job_list = self.cleaned_data['judge_flow']
     flow_mark = ""
     for job in job_list:
         flow_mark += JUDGE_FLOW_MARK_SEPARATOR + str(job)
         
     problem.judge_flow = flow_mark
     session.expire_on_commit = False
     if not update:
         session.add(problem)
     session.commit()
     session.close()
     
     return problem