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