~michael.nelson/open-goal-tracker/switch-to-platform-experiment

« back to all changes in this revision

Viewing changes to src/usergoals/usergoalsteps/views.py

  • Committer: Michael Nelson
  • Date: 2011-10-15 12:06:39 UTC
  • Revision ID: michael.nelson@canonical.com-20111015120639-0kc388mab31lgvwo
Revert removal of action stream stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
            user_goal = step.user_goal
29
29
            action.send(request.user, verb='created step',
30
30
                target=user_goal, action_object=step)
31
 
            return HttpResponseRedirect(user_goal.get_absolute_url())
 
31
 
 
32
            if request.is_ajax():
 
33
                # We want to update the page with the latest action
 
34
                # also.
 
35
                latest_action = user_goal.action_stream_set.all()[0]
 
36
 
 
37
                return render_to_response(
 
38
                    "usergoals/taconite/new_step.xml",
 
39
                    {"goal_step": step, "action": latest_action},
 
40
                    RequestContext(request),
 
41
                    mimetype="text/xml")
 
42
            else:
 
43
                return HttpResponseRedirect(user_goal.get_absolute_url())
32
44
 
33
45
    else:
34
46
        form = UserGoalStepForm(data=dict(user_goal=user_goal.id))
35
47
 
36
 
    return render_to_response(
37
 
        'usergoalsteps/usergoalstep_form.html', {
38
 
            'user_goal': user_goal,
39
 
            'form': form,
40
 
            }, RequestContext(request))
 
48
    if request.is_ajax():
 
49
        assert form.fields['step'].error_messages, "There are no errors"
 
50
        return render_to_response(
 
51
            "usergoals/taconite/new_step.xml", {"form": form},
 
52
            RequestContext(request), mimetype="text/xml")
 
53
    else:
 
54
        return render_to_response(
 
55
            'usergoalsteps/usergoalstep_form.html', {
 
56
                'user_goal': user_goal,
 
57
                'form': form,
 
58
                }, RequestContext(request))
41
59
 
42
60
 
43
61
@login_required