Exemple #1
0
    def update_status(self, new_status):
        """
        Updates the status of this user request and saves itself to the
        database.

        Also triggers notification of the user.

        Arguments:
        new_status  -- the new status of the request (see UserRequestStatus)
        """
        self.status = new_status
        self.save()
        print 'Status of {0} changed to: {1}'.format(
            self.token, UserRequestStatus.const_name(self.status))

        notifier = EmailNotifier()
        notifier.notify_user(self)
    def update_status(self, new_status):
        """
        Updates the status of this user request and saves itself to the
        database.

        Also triggers notification of the user.

        Arguments:
        new_status  -- the new status of the request (see UserRequestStatus)
        """
        self.status = new_status
        self.save()
        print 'Status of {0} changed to: {1}'.format(
            self.token, UserRequestStatus.const_name(self.status))

        notifier = EmailNotifier()
        notifier.notify_user(self)
    def notify_user(self, user_request):
        '''User is notified in case of a change in the UserRequest status
        
        UserRequest instance is providing all data needed to notify the user 
        (user email, UserRequest status)
        
        user_request -- a UserRequest instance
        '''
        from bugex_webapp.models import UserRequest

        status = UserRequestStatus.const_name(user_request.status)
        
        if status not in ('VALID', 'PROCESSING', 'VALIDATING'):
            subject, content = self._get_content(user_request, status)
            try:
                send_mail(subject, content, settings.EMAIL_HOST_USER, 
                          [user_request.user.email], fail_silently=False)
            except Exception as e:
                self.__log.info("Email notification failed: %s", e)
    def notify_user(self, user_request):
        '''User is notified in case of a change in the UserRequest status
        
        UserRequest instance is providing all data needed to notify the user 
        (user email, UserRequest status)
        
        user_request -- a UserRequest instance
        '''
        from bugex_webapp.models import UserRequest

        status = UserRequestStatus.const_name(user_request.status)

        if status not in ('VALID', 'PROCESSING', 'VALIDATING'):
            subject, content = self._get_content(user_request, status)
            try:
                send_mail(subject,
                          content,
                          settings.EMAIL_HOST_USER, [user_request.user.email],
                          fail_silently=False)
            except Exception as e:
                self.__log.info("Email notification failed: %s", e)