def tagadd(request): if request.method == 'POST': form = TagForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('cred:list')) else: form = TagForm() return render(request, 'cred_tagedit.html', {'form': form})
def tagadd(request): if request.method == "POST": form = TagForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse("cred.views.list")) else: form = TagForm() return render(request, "cred_tagedit.html", {"form": form})
def tagadd(request): if request.method == 'POST': form = TagForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('cred.views.list')) else: form = TagForm() return render(request, 'cred_tagedit.html', {'form': form})
def tagedit(request, tag_id): tag = get_object_or_404(Tag, pk=tag_id) if request.method == 'POST': form = TagForm(request.POST, instance=tag) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('cred:list')) else: form = TagForm(instance=tag) return render(request, 'cred_tagedit.html', {'form': form})
def tagedit(request, tag_id): tag = get_object_or_404(Tag, pk=tag_id) if request.method == 'POST': form = TagForm(request.POST, instance=tag) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('cred.views.list')) else: form = TagForm(instance=tag) return render(request, 'cred_tagedit.html', {'form': form})
def createtag(request): if request.method == 'POST': # If the form has been submitted... form = TagForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Process the data in form.cleaned_data # ... form.save() return HttpResponseRedirect('/createpage/') # Redirect after POST else: form = TagForm() # An unbound form return render(request, "createpage/createtag.html", { 'form': form, })
def add_tag(request): """ :param request: :return: """ id = request.GET.get('id', None) if id is not None: tag = get_object_or_404(Tag, id=id) else: tag = None if request.method == 'POST': if request.POST.get('control') == 'delete': tag.delete() messages.add_message(request, messages.INFO, 'Tag deleted') return HttpResponseRedirect(reverse('notes:index')) form = TagForm(request.POST, instance=tag) if form.is_valid(): t = form.save(commit=False) t.slug = slugify(t.label) t.save() messages.add_message(request, messages.INFO, 'Tag deleted') return HttpResponseRedirect(reverse('notes:index')) else: form = TagForm(instance=tag) return render(request, 'notes/addtag.html', {'form': form, 'tag': tag})
def post(self, request, *args, **kwargs): tag_form = TagForm(request.POST) tag_form.is_valid() tagname = tag_form.cleaned_data['name'] tag_count = Tag.objects.filter(name=tagname).count() if tag_count == 0: tag = tag_form.save() else: tag = Tag.objects.get(name=tagname) tagobjectdata = {'tag_id': tag.id, 'object_id': tag_form.cleaned_data['object_id']} tagobject_form = TagObjectForm(tagobjectdata) tagobject_form.is_valid() tagobject_form.save() return self.render_success('done', {'tag':tagname, 'url': tag.get_absolute_url()})
def index(request): form = TagForm() if request.method == 'POST': form = TagForm(request.POST) if form.is_valid(): obj = form.save() obj.client = plan.client obj.save() return render_to_response('iconography/tagupload.html', { 'form': form, 'request': request, }, context_instance=RequestContext(request))
def index(request): form = TagForm() if request.method == 'POST': form = TagForm(request.POST) if form.is_valid(): obj = form.save() obj.client = plan.client obj.save() return render_to_response('iconography/tagupload.html', { 'form' : form, 'request' : request, }, context_instance=RequestContext(request))
def post(self, request, *args, **kwargs): tag_form = TagForm(request.POST) tag_form.is_valid() tagname = tag_form.cleaned_data['name'] tag_count = Tag.objects.filter(name=tagname).count() if tag_count == 0: tag = tag_form.save() else: tag = Tag.objects.get(name=tagname) tagobjectdata = { 'tag_id': tag.id, 'object_id': tag_form.cleaned_data['object_id'] } tagobject_form = TagObjectForm(tagobjectdata) tagobject_form.is_valid() tagobject_form.save() return self.render_success('done', { 'tag': tagname, 'url': tag.get_absolute_url() })