コード例 #1
0
ファイル: models.py プロジェクト: pombredanne/xscheduling
 def wm_sync(self):
   if self.username:
     wm_staff = WorkflowmaxStaff()
     if self.wm_id:
       wm_staff.id = int(self.wm_id)
     wm_staff.name = self.username
     wm_staff.address = str(self.address)
     wm_staff.phone = self.phone
     wm_staff.mobile = self.mobile
     wm_staff.email = self.email
     wm_staff.payrollcode = self.payrollcode
     wm_staff = wm_staff.save()
     if not self.wm_id:
       self.wm_id = wm_staff.id
       self.save()
コード例 #2
0
ファイル: views.py プロジェクト: pombredanne/xscheduling
def add_staff(request):
  context_vars = dict()
  context_vars['header'] = capfirst(_('add new staff'))
  form = StaffForm()
  helper = FormHelper()
  helper.form_class = 'uniform'
  submit = Submit('save',_('save'))
  helper.add_input(submit)
  if request.method == "POST":
    form = StaffForm(request.POST, request.FILES)
    if form.is_valid():
      staff = Staff()
      staff.name = form.cleaned_data['name']
      staff.address = form.cleaned_data['address']
      staff.phone = form.cleaned_data['phone']
      staff.mobile = form.cleaned_data['mobile']
      staff.email = form.cleaned_data['email']
      staff.payrollcode = form.cleaned_data['payrollcode']
      staff = staff.save()
      return HttpResponseRedirect(reverse('workflowmax-staff', args=[staff.id]))
  
  context_vars['form'] = form
  context_vars['helper'] = helper
  return direct_to_template(request, template='workflowmax/form.html', extra_context=context_vars)