예제 #1
0
파일: views.py 프로젝트: Konstantin-5/nerj
def set_to_form_edit_item(request, id):
    data = request.POST.copy()

    errors = []

    if data.has_key('portfolios') and data['portfolios'].strip(', '):
        data['data'] =  data['portfolios'].strip(', ').split(',')
    else:
        data['data'] = []

    portfolios = item_object.get_list_item()

    data['id'] = int(data['id'])


    data, errors = static.valid_item(data.copy())
    post = data.copy()
    style = 'danger'
    function_event = 'set_to_form_edit_item'
    if len(errors) == 0:
        data = static.item_object.update_item(data)
        style = 'success'
        function_event = 'set_to_form_edit_item'
        errors.append(u'Статья успешно отредактирована')

    return render(request, 'types_services/admin/form/add_item.html', {
        'data': data,
        'function_event': function_event,
        'portfolios': portfolios,
        'curents': get_is_to(data),
        'errors': errors,
        'style': style,
        'is_admin_panel': static.is_admin_panel(request),
        })
예제 #2
0
파일: views.py 프로젝트: Konstantin-5/nerj
def to_form_add_item(request, id):

    portfolios = item_object.get_list_item()

    return render(request, 'types_services/admin/form/add_item.html', {
        'data': [],
        'portfolios': portfolios,
        'function_event': 'set_to_form_add_item',
        'errors': [],
        'is_admin_panel': static.is_admin_panel(request),
        })