Exemple #1
0
 def __init__(self, files, current_user, user, pword, message=''):
     self.files = files
     self.user = user
     self.pword = pword
     self.message = message
     self.current = current_user
     self.notifications = {}
     self.BOT_USER = User.objects.get(username=getattr(settings, 'BOT_USERNAME', 'bot'))
     self.notifier = FileUpdateNotification(self.BOT_USER, logger)
Exemple #2
0
class SubmitClient():
    
    def __init__(self, files, current_user, user, pword, message=''):
        self.files = files
        self.user = user
        self.pword = pword
        self.message = message
        self.current = current_user
        self.notifications = {}
        self.BOT_USER = User.objects.get(username=getattr(settings, 'BOT_USERNAME', 'bot'))
        self.notifier = FileUpdateNotification(self.BOT_USER, logger)
        
    def __add_notification(self, user, pofile):
        list = []
        if self.notifications.has_key(user.id):
            list = self.notifications.get(user.id)
        list.append(pofile)
        self.notifications[user.id] = list
    
    def __unlock_submits(self, smfiles):
        for smfile in smfiles:
            smfile.locked = False
            smfile.save()
            
    def __process_notifications(self):
        logger.debug("Init")
        mlist = []
        try:
            for id in self.notifications.keys():
                user = User.objects.get(pk=id)
                with UserLanguage(user) as user_lang:
                    subject = getattr(settings, 'EMAIL_SUBJECT_PREFIX','') + _("Files submitted")
                    message = render_to_string('updater/confirmcommit.mail', {'files': self.notifications.get(id)})
                    mlist.append((subject, message, None, [user.email]))
            send_mass_mail(mlist, True)
            set_user_language(self.current)
            self.notifier.process_notifications()
        except Exception, e:
            logger.error(str(e))
            logger.exception('__process_notifications')
        logger.debug("End")