def new(request): if request.method == 'GET': form = InfoForm() elif request.method == 'POST': data = request.POST.copy() if in_team_secretary( request.user ): data['text'] = u'<strong><u>INFO GESTION:</u></strong> %s' % data['text'] if 'provider' in data.keys() and data['provider']: data['text'] = data['provider'] + " : " + data['text'] form = InfoForm( data = data ) if form.is_valid(): form.save() return redirect('info_index') return render(request, 'infos/new.html', { 'form': form })
def item(request, info_id): info = get_object_or_404( Info, id = info_id ) form = InfoForm(instance = info) if request.method == 'POST': data = request.POST.copy() if 'provider' in data.keys() and data['provider']: data['text'] = data['provider'] + " : " + data['text'] form = InfoForm(instance = info, data = data) if form.is_valid(): form.save() return redirect( 'info_index' ) return render( request, 'infos/item.html', { 'form': form, 'info': info })