1
# Copyright (C) 2012 Linaro
3
# This file is part of linaro-ci-dashboard.
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.
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.
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/>.
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
26
class AndroidLoopUpdateView(UpdateView):
28
template_name = "android_loop_update.html"
29
form_class = AndroidLoopForm
30
context_object_name = 'android_loop_update'
33
form_name = 'android_loop'
35
def form_valid(self, form):
36
"""This method is called when valid form data has been POSTed.
38
It should return an HttpResponse."""
39
return super(AndroidLoopUpdateView, self).form_valid(form)
41
@method_decorator(login_required)
42
def dispatch(self, *args, **kwargs):
43
return super(AndroidLoopUpdateView, self).dispatch(*args, **kwargs)
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
53
def get_success_url(self):
54
'''Return the URL when the form is valid.'''
55
return reverse('AndroidLoopDetail', args=[self.object.name])