Beispiel #1
0
def create(request):
    """
    Saves a tag.
    URL: ^admin/tag/create/$
    """
    variables = dict()
    variables['title'] = _('Create new Tag')
    if request.POST:
        try:
            tag_form = TagForm(request.POST)
            if tag_form.is_valid():
                name = tag_form.cleaned_data['name']
                tag = Tag()
                tag.name = name
                tag.save()
                UpdateTagFilesTask.delay()
                messages.success(request, _('Tag successfully created.'))
                return HttpResponseRedirect(reverse(admin_index))
            else:
                messages.warning(request, _('Correct the errors bellow.'))
        except:
            messages.error(request,
                           _('There was an error while saving the Tag.'))
    else:
        tag_form = TagForm()
    variables['tag_form'] = tag_form
    t = get_template('tag/admin/create.html')
    html = t.render(RequestContext(request, variables))
    return HttpResponse(html)
Beispiel #2
0
def create(request):
    """
    Saves a tag.
    URL: ^admin/tag/create/$
    """
    variables = dict()
    variables['title'] = _('Create new Tag')
    if request.POST:
        try:
            tag_form = TagForm(request.POST)
            if tag_form.is_valid():
                name = tag_form.cleaned_data['name']
                tag = Tag()
                tag.name = name
                tag.save()
                UpdateTagFilesTask.delay()                
                messages.success(request, _('Tag successfully created.'))
                return HttpResponseRedirect(reverse(admin_index))
            else:
                messages.warning(request, _('Correct the errors bellow.'))
        except:
            messages.error(request, _('There was an error while saving the Tag.'))
    else:
        tag_form = TagForm()
    variables['tag_form'] = tag_form
    t = get_template('tag/admin/create.html')
    html = t.render(RequestContext(request, variables))
    return HttpResponse(html)
Beispiel #3
0
def save_tag(tags_string, videopost):
    """
    Saves the tags associated to a Video Post.
    """
    if tags_string.strip():
        tags = tags_string.lower().split(',')
        videopost.tags.clear()
        for tag_name in tags:
            tag_name = tag_name.strip()
            if len(tag_name):
                if Tag.objects.filter(name__iexact=tag_name).count():
                    tag = Tag.objects.get(name__iexact=tag_name)
                else:
                    tag = Tag()
                    tag.name = tag_name
                    tag.save()
                videopost.tags.add(tag)
        videopost.save()
Beispiel #4
0
def save_tag(tags_string, videopost):
    """
    Saves the tags associated to a Video Post.
    """
    if tags_string.strip(): 
        tags = tags_string.lower().split(',')
        videopost.tags.clear()
        for tag_name in tags:
            tag_name = tag_name.strip()
            if len(tag_name):
                if Tag.objects.filter(name__iexact=tag_name).count():
                    tag = Tag.objects.get(name__iexact=tag_name)
                else:
                    tag = Tag()
                    tag.name = tag_name
                    tag.save()                 
                videopost.tags.add(tag)
        videopost.save()