def set_to_form_edit_item(request, id): data = request.POST.copy() data['id'] = int(data['id']) data['seo_id'] = int(data['seo_id']) errors = [] data, errors = static.valid_item(data.copy(), True) post = data.copy() style = 'danger' function_event = 'set_to_form_edit_item' if len(errors) == 0: data = static.item_object.update_item(data) if int(post['seo_id']) > 0: data = static.item_object.update_seo_item(post) elif post['title'].strip() or post['keywords'].strip() or post['description'].strip(): data = static.item_object.insert_seo_item(post) style = 'success' function_event = 'set_to_form_edit_item' errors.append(u'Статья успешно отредактирована') return render(request, 'article/admin/form/add_item.html', { 'data': data, 'function_event': function_event, 'errors': errors, 'style': style, 'is_admin_panel': static.is_admin_panel(request), })
def set_to_form_add_item(request, id): data = request.POST.copy() data['id'] = int(data['id']) data['seo_id'] = int(data['seo_id']) errors = [] data, errors = static.valid_item(data.copy(), False) style = 'danger' function_event = 'set_to_form_add_item' if len(errors) == 0: data = static.item_object.insert_item(data) style = 'success' function_event = 'set_to_form_edit_item' errors.append(u'Статья успешно созданна') return render(request, 'article/admin/form/add_item.html', { 'data': data, 'function_event': function_event, 'errors': errors, 'style': style, 'is_admin_panel': static.is_admin_panel(request), })