~milo/linaro-ci-dashboard/hacking-file

« back to all changes in this revision

Viewing changes to dashboard/frontend/android_build/views/android_loop_update_view.py

  • Committer: Milo Casagrande
  • Date: 2012-08-21 08:13:56 UTC
  • mfrom: (17.6.10 update_view)
  • Revision ID: milo@ubuntu.com-20120821081356-iij1rhbkxldj1zxn
Merged the update view for android build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2012 Linaro
 
2
#
 
3
# This file is part of linaro-ci-dashboard.
 
4
#
 
5
# linaro-ci-dashboard is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU Affero General Public License as published by
 
7
# the Free Software Foundation, either version 3 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# linaro-ci-dashboard is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU Affero General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU Affero General Public License
 
16
# along with linaro-ci-dashboard.  If not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
from django.contrib.auth.decorators import login_required
 
19
from django.core.urlresolvers import reverse
 
20
from django.views.generic.edit import UpdateView
 
21
from django.utils.decorators import method_decorator
 
22
from frontend.android_build.forms.android_loop_form import AndroidLoopForm
 
23
from frontend.android_build.models.android_loop import AndroidLoop
 
24
 
 
25
 
 
26
class AndroidLoopUpdateView(UpdateView):
 
27
 
 
28
    template_name = "android_loop_update.html"
 
29
    form_class = AndroidLoopForm
 
30
    context_object_name = 'android_loop_update'
 
31
    model = AndroidLoop
 
32
    slug_field = "name"
 
33
    form_name = 'android_loop'
 
34
 
 
35
    def form_valid(self, form):
 
36
        """This method is called when valid form data has been POSTed.
 
37
 
 
38
        It should return an HttpResponse."""
 
39
        return super(AndroidLoopUpdateView, self).form_valid(form)
 
40
 
 
41
    @method_decorator(login_required)
 
42
    def dispatch(self, *args, **kwargs):
 
43
        return super(AndroidLoopUpdateView, self).dispatch(*args, **kwargs)
 
44
 
 
45
    def get_context_data(self, **kwargs):
 
46
        '''Get the context data passed to template.'''
 
47
        context = super(AndroidLoopUpdateView,
 
48
                        self).get_context_data(**kwargs)
 
49
        context['request'] = self.request
 
50
        context['form_name'] = self.form_name
 
51
        return context
 
52
 
 
53
    def get_success_url(self):
 
54
        '''Return the URL when the form is valid.'''
 
55
        return reverse('AndroidLoopDetail', args=[self.object.name])