Esempio n. 1
0
    def done(self, request, form_list):
        data = {}
        for form in form_list:
            data.update(form.cleaned_data)

        # Send alert

        alert = Alert(sent_by = data['sent_by'],
                      title = data['title'],
                      details = data['details'],
                      level = data['level'],
            )

        if data['send_to'] == 'all':
            alert_userlist(alert, User.objects.all())

        if data['send_to'] == 'group':
            alert_groups(alert, data['sent_to'])

        if data['send_to'] == 'user':
            alert.sent_to = data['sent_to']
            alert.save()

        
        # Display success message and redirect to changelist:
        return self._model_admin.response_add(request, alert)
Esempio n. 2
0
    def done(self, request, form_list):
        data = {}
        for form in form_list:
            data.update(form.cleaned_data)

        # Send alert

        alert = Alert(
            sent_by=data['sent_by'],
            title=data['title'],
            details=data['details'],
            level=data['level'],
        )

        if data['send_to'] == 'all':
            alert_userlist(alert, User.objects.all())

        if data['send_to'] == 'group':
            alert_groups(alert, data['sent_to'])

        if data['send_to'] == 'user':
            alert.sent_to = data['sent_to']
            alert.save()

        # Display success message and redirect to changelist:
        return self._model_admin.response_add(request, alert)
Esempio n. 3
0
    def test_alert_all(self):
        """
        Tests the ability of the system to alert all users
        """

        # Create a load of users
        for i in range(0, 100):
            User.objects.create(username='******' % (i))

        users = User.objects.all()

        # Create the alert
        alert = Alert(
            sent_by='Tester',
            title='Test title',
            details='No details',
            level='Notice',
        )

        alert_userlist(alert, users)

        self.assertEquals(len(Alert.objects.all()), len(User.objects.all()))
Esempio n. 4
0
    def test_alert_all(self):
        """
        Tests the ability of the system to alert all users
        """

        # Create a load of users
        for i in range(0, 100):
            User.objects.create(username = '******' %(i))

        users = User.objects.all()

        # Create the alert
        alert   =   Alert(
                        sent_by = 'Tester'
                    ,   title   = 'Test title'
                    ,   details = 'No details'
                    ,   level   = 'Notice',
                    )

        alert_userlist(alert, users)

        self.assertEquals(len(Alert.objects.all()), len(User.objects.all()))