示例#1
0
文件: views.py 项目: AkiraKane/Python
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))
示例#2
0
文件: views.py 项目: 5nake/Python-2
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))
示例#3
0
文件: views.py 项目: AkiraKane/Python
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))
示例#4
0
文件: views.py 项目: 5nake/Python-2
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))
示例#5
0
文件: views.py 项目: 5nake/Python-2
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))