Beispiel #1
0
    def _getPrefsPage(self, errorMessage="", statusMessage=""):
        def getNotifyIntervals(selectedOption, includeNone):
            def getDesc(num):
                if num == 0:
                    return 'Ignore'
                elif num == 1:
                    return '1 day'
                else:
                    return str(num) + ' days'

            start = 0
            if not includeNone:
                start = 1
            return [{
                'optionValue': num,
                'optionDesc': getDesc(num),
                'optionSelected': num == selectedOption
            } for num in range(start, 8)]

        # Email notification options
        notifySettings = self.getUserDB().getNotificationSettings(
            self.getUsername())
        repos = []
        for repo in self.getUserDB().getUserRepoPaths(self.getUsername()):
            repos.append({
                'repoName':
                repo,
                'repoID':
                self.getUserDB().getRepoID(self.getUsername(), repo),
                'notifyOptions':
                getNotifyIntervals(notifySettings['repos'][repo], True)
            })

        title = "User Preferences"
        parms = {
            "title":
            title,
            "error":
            errorMessage,
            "message":
            statusMessage,
            "userEmail":
            notifySettings['email'],
            "notificationsEnabled":
            email_notification.emailNotifier().notificationsEnabled(),
            "notifyForAny":
            notifySettings['anyRepoMaxAge'] != 0,
            "notifyOptions":
            getNotifyIntervals(notifySettings['anyRepoMaxAge'], False),
            "notifyRepos":
            repos,
            "backups": [],
            "useZipFormat":
            self.getUserDB().useZipFormat(self.getUsername()),
            "allowRepoDeletion":
            self.getUserDB().allowRepoDeletion(self.getUsername())
        }

        return self.startPage(title) + self.compileTemplate(
            "user_prefs.html", **parms) + self.endPage()
Beispiel #2
0
    def _get_parms_for_page(self):
        email = self.getUserDB().get_email(self.getUsername())
        parms = {
            "userEmail": email,
            "notificationsEnabled": False,
            "backups": [],
            "sampleEmail": self.sampleEmail
        }
        if email_notification.emailNotifier().notificationsEnabled():
            repos = self.getUserDB().get_repos(self.getUsername())
            backups = []
            for repo in repos:
                maxAge = self.getUserDB().get_repo_maxage(
                    self.getUsername(), repo)
                notifyOptions = []
                for i in range(0, 8):
                    notifyStr = "Don't notify"
                    if i == 1:
                        notifyStr = "1 day"
                    elif i > 1:
                        notifyStr = str(i) + " days"

                    selectedStr = ""
                    if i == maxAge:
                        selectedStr = "selected"

                    notifyOptions.append(
                        {"optionStr": notifyStr, "selectedStr": selectedStr})

                backups.append(
                    {"backupName": repo, "notifyOptions": notifyOptions})

            parms.update({"notificationsEnabled": True, "backups": backups})

        return parms
Beispiel #3
0
   def _sendEmails(self):
      if not self._userIsAdmin(): return self.writeErrorPage("Access denied.")

      emailNotifier = email_notification.emailNotifier()
      if emailNotifier.notificationsEnabled():
         emailNotifier.sendEmails()
         return self._generatePageHtml("Email notifications sent.", "")
      else:
         return self._generatePageHtml("", "Email notifications are disabled.")
   def _getPrefsPage(self, errorMessage="", statusMessage=""):
      def getNotifyIntervals(selectedOption, includeNone):
         def getDesc(num):
            if num == 0:
               return 'Ignore'
            elif num == 1:
               return '1 day'
            else:
               return str(num) + ' days'

         start = 0
         if not includeNone:
            start = 1
         return [{
            'optionValue': num,
            'optionDesc': getDesc(num),
            'optionSelected': num == selectedOption
         } for num in range(start, 8)]

      # Email notification options
      notifySettings = self.getUserDB().getNotificationSettings(self.getUsername())
      repos = []
      for repo in self.getUserDB().getUserRepoPaths(self.getUsername()):
         repos.append({
            'repoName': repo,
            'repoID': self.getUserDB().getRepoID(self.getUsername(), repo),
            'notifyOptions': getNotifyIntervals(notifySettings['repos'][repo],
                                                True)
         })

      title = "User Preferences"
      parms = {
         "title" : title,
         "error" : errorMessage,
         "message" : statusMessage,
         "userEmail" : notifySettings['email'],
         "notificationsEnabled" : email_notification.emailNotifier().notificationsEnabled(),
         "notifyForAny": notifySettings['anyRepoMaxAge'] != 0,
         "notifyOptions": getNotifyIntervals(notifySettings['anyRepoMaxAge'],
                                             False),
         "notifyRepos": repos,
         "backups" : [],
         "useZipFormat": self.getUserDB().useZipFormat(self.getUsername()),
         "allowRepoDeletion": self.getUserDB().allowRepoDeletion(self.getUsername())
      }

      return self.startPage(title) + self.compileTemplate("user_prefs.html", **parms) + self.endPage()
Beispiel #5
0
    def _getPrefsPage(self, errorMessage="", statusMessage=""):
        title = "User Preferences"
        email = self.getUserDB().getUserEmail(self.getUsername())
        parms = {
            "title": title,
            "error": errorMessage,
            "message": statusMessage,
            "userEmail": email,
            "notificationsEnabled": False,
            "backups": [],
            "useZipFormat": self.getUserDB().useZipFormat(self.getUsername()),
            "sampleEmail": self.sampleEmail
        }
        if email_notification.emailNotifier().notificationsEnabled():
            repos = self.getUserDB().getUserRepoPaths(self.getUsername())
            backups = []
            for repo in repos:
                maxAge = self.getUserDB().getRepoMaxAge(
                    self.getUsername(), repo)
                notifyOptions = []
                for i in range(0, 8):
                    notifyStr = "Don't notify"
                    if i == 1:
                        notifyStr = "1 day"
                    elif i > 1:
                        notifyStr = str(i) + " days"

                    selectedStr = ""
                    if i == maxAge:
                        selectedStr = "selected"

                    notifyOptions.append({
                        "optionStr": notifyStr,
                        "selectedStr": selectedStr
                    })

                backups.append({
                    "backupName": repo,
                    "notifyOptions": notifyOptions
                })

            parms.update({"notificationsEnabled": True, "backups": backups})

        return self.startPage(title) + self.compileTemplate(
            "user_prefs.html", **parms) + self.endPage()
    def _getPrefsPage(self, errorMessage="", statusMessage=""):
        title = "User Preferences"
        email = self.userDB.getUserEmail(self.getUsername())
        parms = {
            "title": title,
            "error": errorMessage,
            "message": statusMessage,
            "userEmail": email,
            "notificationsEnabled": False,
            "backups": [],
            "useZipFormat": self.userDB.useZipFormat(self.getUsername()),
            "sampleEmail": self.sampleEmail,
        }
        if email_notification.emailNotifier().notificationsEnabled():
            repos = self.userDB.getUserRepoPaths(self.getUsername())
            backups = []
            for repo in repos:
                maxAge = self.userDB.getRepoMaxAge(self.getUsername(), repo)
                notifyOptions = []
                for i in range(0, 8):
                    notifyStr = "Don't notify"
                    if i == 1:
                        notifyStr = "1 day"
                    elif i > 1:
                        notifyStr = str(i) + " days"

                    selectedStr = ""
                    if i == maxAge:
                        selectedStr = "selected"

                    notifyOptions.append({"optionStr": notifyStr, "selectedStr": selectedStr})

                backups.append({"backupName": repo, "notifyOptions": notifyOptions})

            parms.update({"notificationsEnabled": True, "backups": backups})

        return self.startPage(title) + self.compileTemplate("user_prefs.html", **parms) + self.endPage()