Exemple #1
0
def shownote(request):
    if request.method == 'GET': 
        agendas = AgendaDB.objects().order_by('-date')
        return render(request, 'edit_shownote.html', 
                      {'agendas': agendas 
                       , 'agendaform': AgendaForm()
                       , 'shownoteform': ShownoteForm() 
                       } )

    elif request.method == 'POST': 
        form = ShownoteForm(request.POST) 
        if form.is_valid(): 
            number = FikanoteDB.objects().count()+1
            # add to shownote
            shownotes = []
            list_title = request.POST.getlist('agenda_title')
            list_url = request.POST.getlist('agenda_url')
            list_id = request.POST.getlist('agenda_id')
            for i in range(len(list_title)):
                shownotes.append(Shownote(title=list_title[i], url=list_url[i]))
            FikanoteDB(number = number
                       , title=form.cleaned_data['title']
                       , person=form.cleaned_data['person'].split(",")
                       , agenda=form.cleaned_data['agenda']
                       , date=datetime.datetime.utcnow()
                       , shownotes=shownotes
                       ).save()
            # delete id's item from agendadb
            for i in range(len(list_id)):
                AgendaDB.objects.filter(id__exact=list_id[i]).delete()

        return HttpResponseRedirect('/') 
        
    else:
        raise Http404
Exemple #2
0
def episode(request, number):
    episode = FikanoteDB.objects(number=int(number)).first()
    if episode is None:
        return HttpResponsePermanentRedirect('/')

    person = episode['person']
    shownotes = episode['shownotes']

    return render(request, 'episode.html',
                  {'episode': episode,
                   'person': person,
                   'shownotes': shownotes,
                   })
Exemple #3
0
def shownote(request):
    if request.method == 'GET':
        agendas = AgendaDB.objects().order_by('-date')
        return render(
            request, 'edit_shownote.html', {
                'agendas': agendas,
                'agendaform': AgendaForm(),
                'shownoteform': ShownoteForm(),
            })

    elif request.method == 'POST':
        form = ShownoteForm(request.POST)
        if form.is_valid():
            number = FikanoteDB.objects().count() + 1
            # add to shownote
            shownotes = []
            list_title = request.POST.getlist('agenda_title')
            list_url = request.POST.getlist('agenda_url')
            list_id = request.POST.getlist('agenda_id')
            for i in range(len(list_title)):
                shownotes.append(Shownote(title=list_title[i],
                                          url=list_url[i]))
            if len(shownotes) == 0:
                return HttpResponseRedirect('/')
            FikanoteDB(number=number,
                       title=form.cleaned_data['title'],
                       person=form.cleaned_data['person'].split(","),
                       agenda=form.cleaned_data['agenda'],
                       date=datetime.datetime.utcnow(),
                       shownotes=shownotes).save()
            # delete id's item from agendadb
            for i in range(len(list_id)):
                AgendaDB.objects.filter(id__exact=list_id[i]).delete()
            return episode(request, number)

        return HttpResponseRedirect('/')

    else:
        raise Http404
Exemple #4
0
def episode(request, number):
    episode = FikanoteDB.objects(number=int(number)).first()
    if episode is None:
        return HttpResponsePermanentRedirect('/') 

    person = episode['person']
    shownotes = episode['shownotes']

    return render(request, 'episode.html', 
                  {'episode': episode, 
                   'person' : person,
                   'shownotes' : shownotes,
                   } )