Exemplo n.º 1
0
def add(request):
    '''
    Add new show info
    '''  
    
    if request.method == "POST":
        form = ShowForm(request.POST, request.FILES)
        
        if form.is_valid():
            obj = form.save(commit=False)
            obj.creator = request.user
            obj.created = datetime.now()
            obj.save()
            if obj.imdb_poster:
                save_poster(obj, obj.imdb_poster)
            if form.data['cast'] != '':
                add_cast(obj, form.data['cast'], request.user)
            if form.data['genre'] != '':
                add_genre(obj, form.data['genre'])    
            obj.save()
            # start the back ground prossess to find all episodes
            fillShowEpisodesTask.delay(obj.title_en)
            return HttpResponseRedirect(reverse("show_item", args=[obj.slug]))
    else:
        form = ShowForm()
        
    template = 'shows/show_edit.html'
    data = { 'form': form, }
    
    return render_to_response(template, data , context_instance=RequestContext(request))
Exemplo n.º 2
0
def add(request):
    if request.method == 'POST':
        search_form = ShowSearchForm(request.POST)
        if search_form.is_valid():
            show_query = search_form.cleaned_data['show']
            tv = Tvdb()
            try:
                show = tv[show_query]
            except tvdb_shownotfound, e:
                search_form = e.message
                error_msg = e.message # TODO: use errorlist instead?
            except tvdb_error, e:
                error_msg = e.message
            else:
                show_data = {
                    'name': show.data['seriesname'],
                    'description': show.data['overview'],
                    'actors': show.data['actors'],
                    'genre': show.data['genre'],
                    'status': show.data['status'],
                    'imdb_id': show.data['imdb_id'],
                    'zap2it_id': show.data['zap2it_id']
                }
                show_form = ShowForm(show_data)
                if show_form.is_valid():
                    new_show = show_form.save()
Exemplo n.º 3
0
def edit(request, slug):
    '''
    Edit show info
    '''
    show, created = Show.objects.get_or_create(slug=slug)
    
    if request.method == "POST":
        form = ShowForm(request.POST, request.FILES, instance=show)
        if form.is_valid():
            obj = form.save(commit=False)
            
            if obj.imdb_poster:
                save_poster(obj, obj.imdb_poster)
            if form.data['cast'] != '':
                add_cast(obj, form.data['cast'], request.user)
            if form.data['genre'] != '':
                add_genre(obj, form.data['genre'])
            obj.save()
            return HttpResponseRedirect(reverse("show_item", args=[obj.slug]))
    else:
        form = ShowForm(instance=show)
        
    template = 'shows/show_edit.html'
    data = { 'form': form, 'edit': True}
    
    return render_to_response(template, data , context_instance=RequestContext(request))