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

    user = User.objects.get(username=username)
    form = TrackerForm(request.POST or None)
    if form.is_valid():
        thisGoal = form.cleaned_data['goal']
        thisDate = form.cleaned_data['date']
        thisTitle = form.cleaned_data['title']
        thisContent = form.cleaned_data['content']
        thisHours = form.cleaned_data['hours']
        thisRemark = form.cleaned_data['remark']
        thisUser = User.objects.get(username=username)

        tracker = Tracker(user=thisUser, \
                          goal=thisGoal, \
                          date=thisDate, \
                          title=thisTitle, \
                          content=thisContent, \
                          hours=thisHours, \
                          remark=thisRemark)
        tracker.save()


        return HttpResponseRedirect(URL_DASHBOARD(user.username))

    return HttpResponseRedirect(URL_DASHBOARD(username))
Exemplo n.º 2
0
def HoursManageAddView(request, username=''):

    user = User.objects.get(username=username)
    form = TrackerForm(request.POST or None)
    if form.is_valid():
        thisGoal = form.cleaned_data['goal']
        thisDate = form.cleaned_data['date']
        thisTitle = form.cleaned_data['title']
        thisContent = form.cleaned_data['content']
        thisHours = form.cleaned_data['hours']
        thisRemark = form.cleaned_data['remark']
        thisUser = User.objects.get(username=username)

        tracker = Tracker(user=thisUser, \
                          goal=thisGoal, \
                          date=thisDate, \
                          title=thisTitle, \
                          content=thisContent, \
                          hours=thisHours, \
                          remark=thisRemark)
        tracker.save()

        return HttpResponseRedirect(URL_DASHBOARD(user.username))

    return HttpResponseRedirect(URL_DASHBOARD(username))
Exemplo n.º 3
0
def HoursManageUpdateView(request, username='', trackerid=''):
 
    tracker = Tracker.objects.get(id=trackerid)
    user = User.objects.get(username=username)

    form = TrackerForm(request.POST or None)


    if form.is_valid():
        tracker.goal = form.cleaned_data['goal']
        tracker.date = form.cleaned_data['date']
        tracker.title = form.cleaned_data['title']
        tracker.content = form.cleaned_data['content']
        tracker.hours = form.cleaned_data['hours']
        tracker.remark = form.cleaned_data['remark']
        tracker.save()

        return HttpResponseRedirect(URL_DASHBOARD(user.username))
    else:
        template_name = 'master/hours10k_manage_update.html'
        template_value = {'form': form, 'tracker': tracker, 'user': user}
        return render_to_response(template_name, template_value, context_instance=RequestContext(request))
Exemplo n.º 4
0
def HoursManageUpdateView(request, username='', trackerid=''):

    tracker = Tracker.objects.get(id=trackerid)
    user = User.objects.get(username=username)

    form = TrackerForm(request.POST or None)

    if form.is_valid():
        tracker.goal = form.cleaned_data['goal']
        tracker.date = form.cleaned_data['date']
        tracker.title = form.cleaned_data['title']
        tracker.content = form.cleaned_data['content']
        tracker.hours = form.cleaned_data['hours']
        tracker.remark = form.cleaned_data['remark']
        tracker.save()

        return HttpResponseRedirect(URL_DASHBOARD(user.username))
    else:
        template_name = 'master/hours10k_manage_update.html'
        template_value = {'form': form, 'tracker': tracker, 'user': user}
        return render_to_response(template_name,
                                  template_value,
                                  context_instance=RequestContext(request))
Exemplo n.º 5
0
def DashboardView(request, username=''):

    user = User.objects.get(username=username)

    # Goals:
    ## Todo
    todo_form = TodoForm()
    todos = Todo.objects.filter(user_id=user.id, status=1)  # list all undos
    ## 10K Hours
    tracker_form = TrackerForm()
    trackers = Tracker.objects.filter(user_id=user.id)
    ## Event
    event_form = EventForm()
    events = Event.objects.filter(user_id=user.id)

    # Life:
    ## Mood
    mood_form = MoodForm()
    moods = Mood.objects.filter(user_id=user.id)
    ## Dream
    dream_form = DreamForm()
    dreams = Dream.objects.filter(user_id=user.id)
    ## Diary
    diary_form = DiaryForm()
    diaries = Diary.objects.filter(user_id=user.id)

    # Rendering template
    template_name = 'master/dashboard.html'
    template_value = {
        'TodoForm': todo_form,
        'todos': todos,
        'EventForm': event_form,
        'events': events,
        'TrackerForm': tracker_form,
        'trackers': trackers,
        'MoodForm': mood_form,
        'moods': moods,
        'DreamForm': dream_form,
        'dreams': dreams,
        'DiaryForm': diary_form,
        'diaries': diaries,
    }
    return render_to_response(template_name,
                              template_value,
                              context_instance=RequestContext(request))