def list_item(request): settings.PAGINATION_PER_PAGE = 4 if static.is_admin_panel(request): data = static.item_object.get_list_item() else: data = static.item_object.get_list_item_active() data = simple_paginate(data, request, style='digg') return render(request, 'article/list_item.html', { 'is_admin_panel': static.is_admin_panel(request), 'paginator': data, })
def to_form_add_item(request, id): return render(request, 'article/admin/form/add_item.html', { 'data': [], 'function_event': 'set_to_form_add_item', 'errors': [], 'is_admin_panel': static.is_admin_panel(request), })
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_gallery(request, id): data = request.POST.copy() errors = [] id_item = data['id_item'] function_event = 'set_to_form_add_gallery' style = 'danger' errors = [] data, errors = static.valid_gallery(data.copy()) if len(errors) == 0: data = static.item_object.insert_gallery(data, id_item) style = 'success' function_event = 'set_to_form_edit_gallery' errors.append(u'Галлерея успешно созданна') return render(request, 'article/admin/form/add_gallery.html', { 'data': data, 'id_item': id_item, 'function_event': function_event, 'errors': errors, 'style': style, 'is_admin_panel': static.is_admin_panel(request), })
def to_form_edit_item(request, id): data = static.item_object.get_item_id(id) return render(request, 'article/admin/form/add_item.html', { 'data': data, 'function_event': 'set_to_form_edit_item', 'errors': [], 'is_admin_panel': static.is_admin_panel(request), })
def item(request, url): data = static.item_object.get_item_url_active(url) if not data: raise Http404 data.count_views += 1 data.save() return render(request, 'article/item.html', { 'item': data, '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), })