예제 #1
0
    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())
예제 #2
0
    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())
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
 def process_request(self, request):
     if maintenance.is_enabled() and not request.user.is_staff:
         return view_503(request)
     return
예제 #6
0
 def test_maintenance_check_empty_table(self):
     self.assertFalse(maintenance.is_enabled())
     self.assertFalse(Config.objects.get(key='maintenance').value)
예제 #7
0
 def test_maintenance_check_empty_table(self):
     self.assertFalse(maintenance.is_enabled())
     self.assertFalse(Config.objects.get(key='maintenance').value)
예제 #8
0
 def process_request(self, request):
     if maintenance.is_enabled() and not request.user.is_staff:
         return view_503(request)
     return