Esempio n. 1
0
    def save(self):
        # We want this instance created by .create() so we will ignore self.instance
        # which is created just by model(**data)
        data = self.cleaned_data.copy()

        self.instance = self.request.user.inbox_set.create(**data)
        inbox_ratelimit.counter_increase(self.request)

        msg = _("{0}@{1} has been created.").format(
            self.instance.inbox, self.instance.domain.domain)
        messages.success(self.request, msg)
        return self.instance
Esempio n. 2
0
    def save(self):
        # We want this instance created by .create() so we will ignore self.instance
        # which is created just by model(**data)
        data = self.cleaned_data.copy()

        self.instance = self.request.user.inbox_set.create(**data)
        self.instance.update_search()
        self.instance.save()
        inbox_ratelimit.counter_increase(self.request)

        msg = _("{0}@{1} has been created.").format(self.instance.inbox, self.instance.domain.domain)
        messages.success(self.request, msg)
        return self.instance
Esempio n. 3
0
    def test_inbox_ratelimit_valid_keys(self):
        request = MockRequest(self.user)

        cache_prefix = u"hello€@.+-_ <>"

        with override_settings(INBOX_LIMIT_CACHE_PREFIX=cache_prefix), \
                warnings.catch_warnings(record=True) as w:
            self.assertEqual(inbox_ratelimit.counter_full(request), False)

            for i in range(settings.INBOX_LIMIT_COUNT + 1):
                inbox_ratelimit.counter_increase(request)

            self.assertEqual(inbox_ratelimit.counter_full(request), True)

        self.assertEqual(len(w), 0)
Esempio n. 4
0
    def test_inbox_ratelimit_valid_keys(self):
        request = MockRequest(self.user)

        cache_prefix = u"hello€@.+-_ <>"

        with override_settings(INBOX_LIMIT_CACHE_PREFIX=cache_prefix), \
                warnings.catch_warnings(record=True) as w:
            self.assertEqual(inbox_ratelimit.counter_full(request), False)

            for i in range(settings.INBOX_LIMIT_COUNT + 1):
                inbox_ratelimit.counter_increase(request)

            self.assertEqual(inbox_ratelimit.counter_full(request), True)

        self.assertEqual(len(w), 0)
Esempio n. 5
0
    def save(self):
        # We want this instance created by .create() so we will ignore self.instance
        # which is created just by model(**data)
        data = self.cleaned_data.copy()
        description = data.pop("description")
        excludes = data.pop("exclude_from_unified", False)

        self.instance = self.request.user.inbox_set.create(**data)
        self.instance.description = description
        self.instance.flags.exclude_from_unified = excludes
        self.instance.save()
        inbox_ratelimit.counter_increase(self.request)

        msg = _("{0}@{1} has been created.").format(
            self.instance.inbox, self.instance.domain.domain)
        messages.success(self.request, msg)
        return self.instance