Skip to content
Browse files

ticket6: pep8, input readonly

  • Loading branch information...
1 parent 31b9007 commit fef71af09cfe9b5bb500bb87bde60e349b1755c1 @andreysobol committed Mar 11, 2012
Showing with 10 additions and 7 deletions.
  1. +3 −4 testsobol/mainapp/tests.py
  2. +3 −3 testsobol/mainapp/views.py
  3. +4 −0 testsobol/static/custom.js
View
7 testsobol/mainapp/tests.py
@@ -85,14 +85,13 @@ def test(self):
class AjaxEdit(TestCase):
def test(self):
- fixtures = ['initial_data.json']
-
- page = self.client.post('/accounts/login/', {'username': 'admin', 'password': 'admin'})
+ page = self.client.post('/accounts/login/',
+ {'username': 'admin', 'password': 'admin'})
self.assertEqual(page.status_code, 302)
page = self.client.post('/edit/')
self.assertTrue(page.content.find('<body>') == -1)
-
+
page = self.client.get('/edit/')
self.assertTrue(page.content.find('<body>') != -1)
self.assertTrue(page.content.find('<script') != -1)
View
6 testsobol/mainapp/views.py
@@ -1,6 +1,6 @@
from django.views.generic import View, TemplateView, ListView
from django.forms.models import model_to_dict
-from django.shortcuts import redirect, render_to_response
+from django.shortcuts import render_to_response
from django.template import RequestContext
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
@@ -20,7 +20,7 @@ def get_context_data(self, **kwargs):
class Edit(View):
-
+
def render(self, request, form, temp):
return render_to_response(temp,
RequestContext(request, {'renders': form.render(), 'form': True}))
@@ -31,7 +31,7 @@ def dispatch(self, request, *args, **kwargs):
def get(self, request):
form = BioForm(model_to_dict(Bio.objects.get(pk=1)),
- {'img':Bio.objects.get(pk=1).img})
+ {'img': Bio.objects.get(pk=1).img})
return self.render(request, form, 'index.html')
def post(self, request):
View
4 testsobol/static/custom.js
@@ -20,6 +20,8 @@ $(function(){
url:'/edit/',
type: 'post',
success: function(response){
+ $('input').removeAttr('readonly');
+ $('textarea').removeAttr('readonly');
if(response=="Okay"){
$('.mess').html('Bio update. <a href="/">View.</a>');
$('.error').css('display','none');
@@ -33,6 +35,8 @@ $(function(){
},
beforeSubmit: function(){
$('input[type="submit"]').css('display','none');
+ $('input').attr('readonly','readonly');
+ $('textarea').attr('readonly','readonly');
$('.mess').html('<img src="/static/ajax-loader.gif" style="width:32px;"/>');
}
}

0 comments on commit fef71af

Please sign in to comment.
Something went wrong with that request. Please try again.