def test_maintenance_check(self): option = Config.objects.create(key='maintenance', value=False) self.assertFalse(maintenance.is_enabled()) option.value = True option.save() self.assertTrue(maintenance.is_enabled())
def process_response(self, request, response): if maintenance.is_enabled( ) and request.user.is_staff and self.is_html_response(response): template = get_template('admin_warning.html') warning_message = template.render(Context()) response.content = re.sub(r'<body.*>', '\g<0>' + warning_message, response.content) return response
def process_response(self, request, response): if maintenance.is_enabled() and request.user.is_staff and self.is_html_response(response): template = get_template('admin_warning.html') warning_message = template.render(Context()) response.content = re.sub(ur'<body.*>', u'\g<0>' + warning_message, unicode(response.content, "utf-8")) return response
def process_request(self, request): if maintenance.is_enabled() and not request.user.is_staff: return view_503(request) return
def test_maintenance_check_empty_table(self): self.assertFalse(maintenance.is_enabled()) self.assertFalse(Config.objects.get(key='maintenance').value)