Exemple #1
0
 def test_set_maintenance(self):
     set_maintenance_mode(True, 'test')
     info = get_maintenance_mode()
     self.assertEqual('test', info['message'])
     self.assertEqual(True, info['state'])
     set_maintenance_mode(False)
     info = get_maintenance_mode()
     self.assertEqual('', info['message'])
     self.assertEqual(False, info['state'])
Exemple #2
0
 def test_set_maintenance(self):
     set_maintenance_mode(True, "test")
     info = get_maintenance_mode()
     self.assertEquals("test", info["message"])
     self.assertEquals(True, info["state"])
     set_maintenance_mode(False)
     info = get_maintenance_mode()
     self.assertEquals("", info["message"])
     self.assertEquals(False, info["state"])
Exemple #3
0
 def test_set_maintenance(self):
     set_maintenance_mode(True, 'test')
     info = get_maintenance_mode()
     self.assertEqual('test', info['message'])
     self.assertEqual(True, info['state'])
     set_maintenance_mode(False)
     info = get_maintenance_mode()
     self.assertEqual('', info['message'])
     self.assertEqual(False, info['state'])
Exemple #4
0
 def test_admin_change_message(self):
     set_maintenance_mode(False)
     self.client.login(username="******")
     self.client.post(reverse("set_maintenance_mode"), {"message": "new test message", "set_button": 1})
     info = get_maintenance_mode()
     self.assertEquals("new test message", info["message"])
     self.assertEquals(True, info["state"])
     self.client.post(reverse("set_maintenance_mode"), {"turn_off_button": 1})
     info = get_maintenance_mode()
     self.assertEquals(False, info["state"])
Exemple #5
0
 def test_admin_change_message(self):
     set_maintenance_mode(False)
     self.client.login(username='******')
     self.client.post(reverse('set_maintenance_mode'), {
         'message': 'new test message',
         'set_button': 1,
     })
     info = get_maintenance_mode()
     self.assertEquals('new test message', info['message'])
     self.assertEquals(True, info['state'])
     self.client.post(reverse('set_maintenance_mode'), {
         'turn_off_button': 1,
     })
     info = get_maintenance_mode()
     self.assertEquals(False, info['state'])
Exemple #6
0
 def test_admin_change_message(self):
     set_maintenance_mode(False)
     self.assertTrue(self.client.login(username='******'))
     self.client.post(reverse('set_maintenance_mode'), {
         'message': 'new test message',
         'set_button': 1,
     })
     info = get_maintenance_mode()
     self.assertEqual('new test message', info['message'])
     self.assertEqual(True, info['state'])
     self.client.post(reverse('set_maintenance_mode'), {
         'turn_off_button': 1,
     })
     info = get_maintenance_mode()
     self.assertEqual(False, info['state'])
Exemple #7
0
def maintenance_view(request):
    # We don't want users to access maintenance site
    # when maintenance is disabled.
    if not is_maintenance_mode_enabled():
        return HttpResponseRedirect('/')
    maintenance_info = get_maintenance_mode()
    return render(request, 'maintenance.html',
                  {'message': maintenance_info['message']})
Exemple #8
0
def maintenance_view(request):
    # We don't want users to access maintenance site
    # when maintenance is disabled.
    if not is_maintenance_mode_enabled():
        return HttpResponseRedirect('/')
    maintenance_info = get_maintenance_mode()
    return render(request, 'maintenance.html',
                  {'message': maintenance_info['message']})
Exemple #9
0
def set_maintenance_mode_view(request):
    if request.method == 'POST':
        if 'set_button' in request.POST:
            message = request.POST['message']
            set_maintenance_mode(True, message)
        elif 'turn_off_button' in request.POST:
            set_maintenance_mode(False)

    maintenance_info = get_maintenance_mode()
    return render(request, 'set_maintenance.html',
                  {
                      'message': maintenance_info['message'],
                      'state': maintenance_info['state'],
                  })
Exemple #10
0
def set_maintenance_mode_view(request):
    if request.method == 'POST':
        if 'set_button' in request.POST:
            message = request.POST['message']
            set_maintenance_mode(True, message)
        elif 'turn_off_button' in request.POST:
            set_maintenance_mode(False)

    maintenance_info = get_maintenance_mode()
    return render(request, 'set_maintenance.html',
                  {
                      'message': maintenance_info['message'],
                      'state': maintenance_info['state'],
                  })