Exemplo n.º 1
0
 def dismiss_ui_notify(self, in_data):
     if 'slug' not in in_data:
         raise JSONResponseException('slug for ui notify is required')
     DismissedUINotify.dismiss_notification(self.request.user, in_data['slug'])
     return {
         'dismissed': DismissedUINotify.is_notification_dismissed(self.request.user, in_data['slug'])
     }
Exemplo n.º 2
0
    def enabled(self, request):
        if settings.ENTERPRISE_MODE:
            return False

        if hasattr(request, 'user'):
            from corehq.apps.notifications.models import DismissedUINotify

            today = datetime.now()

            if self.starts_on is not None and self.starts_on >= today:
                return False

            if self.ends_on is not None and self.ends_on <= today:
                return False

            if (self.visible_to_users_before is not None
                    and was_user_created_after(request.user.username,
                                               self.visible_to_users_before)):
                return False

            if (self.visible_to_users_after is not None
                    and not was_user_created_after(
                        request.user.username, self.visible_to_users_after)):
                return False

            return not DismissedUINotify.is_notification_dismissed(
                request.user, self.slug)
        return False
Exemplo n.º 3
0
    def enabled(self, request):
        if settings.ENTERPRISE_MODE:
            return False

        if hasattr(request, 'user'):
            from corehq.apps.notifications.models import DismissedUINotify

            today = datetime.now()

            if self.starts_on is not None and self.starts_on >= today:
                return False

            if self.ends_on is not None and self.ends_on <= today:
                return False

            if (self.visible_to_users_before is not None
                and was_user_created_after(
                    request.user.username,
                    self.visible_to_users_before)):
                return False

            if (self.visible_to_users_after is not None
                and not was_user_created_after(
                    request.user.username,
                    self.visible_to_users_after)):
                return False

            return not DismissedUINotify.is_notification_dismissed(
                request.user, self.slug
            )
        return False