def add_jobs(request): def _add_jobs(form): jobs = form.save(commit=False) jobs.save() return {'ret_code': RET_CODES["ok"]} return with_valid_form(JobsForm(request.POST), _add_jobs)
def add_page(request): def _add_page(form): page = form.save(commit=False) page.account = Account.objects.get(user__pk=request.user.pk) page.save() return {'ret_code': RET_CODES["ok"]} return with_valid_form(PageForm(request.POST), _add_page)
def add_dishes(request): def _add_dishes(form): form.save() return {'ret_code': RET_CODES["ok"]} return with_valid_form(DishesForm(request.POST), _add_dishes)
def add_talk(request): def _add_talk(form): form.save() return {'ret_code': RET_CODES["ok"]} return with_valid_form(TalkForm(request.POST), _add_talk)
def edit_talk(request, id): talk = Talk.objects.get(pk=id) form = TalkForm(request.POST, instance=talk) def _edit_talk(form): form.save() return {"ret_code": RET_CODES["ok"]} return with_valid_form(form, _edit_talk)
def edit_jobs(request, id): jobs = Jobs.objects.get(pk=id) form = JobsForm(request.POST, instance=jobs) def _edit_jobs(form): form.save() return {'ret_code': RET_CODES["ok"]} return with_valid_form(form, _edit_jobs)
def edit_show(request, id): show = Magician_Show.objects.get(pk=id) form = ShowForm(request.POST, instance=show) def _edit_show(form): form.save() return {'ret_code': RET_CODES["ok"]} return with_valid_form(form, _edit_show)
def edit_dishes(request, id): dishes = Dishes.objects.get(pk=id) form = DishesForm(request.POST, instance=dishes) def _edit_dishes(form): form.save() return {'ret_code': RET_CODES["ok"]} return with_valid_form(form, _edit_dishes)
def edit_talk(request, id): talk = Talk.objects.get(pk=id) form = TalkForm(request.POST, instance=talk) def _edit_talk(form): form.save() return {'ret_code': RET_CODES["ok"]} return with_valid_form(form, _edit_talk)
def edit_page(request, id): account = Account.objects.get(user__pk=request.user.pk) page = Page.objects.get(pk=id, account=account) form = PageForm(request.POST, instance=page) def _edit_page(form): form.save() if len(PageItem.objects.filter(page=page)) > 0: wps.emitChangeEvent(account) return {'ret_code': RET_CODES["ok"]} return with_valid_form(form, _edit_page)