Exemplo n.º 1
0
def MoodManageAddView(request, username=''):

    user = User.objects.get(username=username)
    form = MoodForm(request.POST or None)
    if form.is_valid():
        thisDate = form.cleaned_data['date']
        thisRating = form.cleaned_data['rating']
        thisKeywords = form.cleaned_data['keywords']
        thisUser = User.objects.get(username=username)

        mood = Mood(user=thisUser, date=thisDate, rating=thisRating, keywords=thisKeywords)
        mood.save()

        return HttpResponseRedirect(URL_DASHBOARD(user.username))

    return HttpResponseRedirect(URL_DASHBOARD(username))
Exemplo n.º 2
0
def MoodManageUpdateView(request, username='', moodid=''):
 
    mood = Mood.objects.get(id=moodid)
    user = User.objects.get(username=username)

    form = MoodForm(request.POST or None)


    if form.is_valid():
        mood.date = form.cleaned_data['date']
        mood.rating = form.cleaned_data['rating']
        mood.keywords = form.cleaned_data['keywords']
        mood.save()

        return HttpResponseRedirect(URL_DASHBOARD(user.username))
    else:
        template_name = 'master/mood_manage_update.html'
        template_value = {'form': form, 'mood': mood, 'user': user}
        return render_to_response(template_name, template_value, context_instance=RequestContext(request))
Exemplo n.º 3
0
def MoodManageAddView(request, username=''):

    user = User.objects.get(username=username)
    form = MoodForm(request.POST or None)
    if form.is_valid():
        thisDate = form.cleaned_data['date']
        thisRating = form.cleaned_data['rating']
        thisKeywords = form.cleaned_data['keywords']
        thisUser = User.objects.get(username=username)

        mood = Mood(user=thisUser,
                    date=thisDate,
                    rating=thisRating,
                    keywords=thisKeywords)
        mood.save()

        return HttpResponseRedirect(URL_DASHBOARD(user.username))

    return HttpResponseRedirect(URL_DASHBOARD(username))
Exemplo n.º 4
0
def MoodManageUpdateView(request, username='', moodid=''):

    mood = Mood.objects.get(id=moodid)
    user = User.objects.get(username=username)

    form = MoodForm(request.POST or None)

    if form.is_valid():
        mood.date = form.cleaned_data['date']
        mood.rating = form.cleaned_data['rating']
        mood.keywords = form.cleaned_data['keywords']
        mood.save()

        return HttpResponseRedirect(URL_DASHBOARD(user.username))
    else:
        template_name = 'master/mood_manage_update.html'
        template_value = {'form': form, 'mood': mood, 'user': user}
        return render_to_response(template_name,
                                  template_value,
                                  context_instance=RequestContext(request))