コード例 #1
0
ファイル: controllers.py プロジェクト: murgo/IrssiNotifier
    def initController(self, name, paramRequirements):
        logging.info("Method started: %s" % name)

        if len(self.request.params) > 0:
            self.data = self.request.params
        else:
            try:
                self.data = self.decode_params(self.request)
            except:
                # because of weird assertion error
                self.data = {}

        logging.debug("Data {0}".format(self.data))

        self.irssi_user = login.get_irssi_user(self.data)
        if not self.irssi_user:
            self.response.status = "401 Unauthorized"
            return False

        if not self.validate_params(self.data, paramRequirements):
            self.response.status = "400 Bad Request"
            return False
        return True
コード例 #2
0
    def initController(self, name, paramRequirements):
        logging.info("Method started: %s" % name)

        if len(self.request.params) > 0:
            self.data = self.request.params
        else:
            try:
                self.data = self.decode_params(self.request)
            except:
                # because of weird assertion error
                self.data = {}

        logging.debug("Data {0}".format(self.data))

        self.irssi_user = login.get_irssi_user(self.data)
        if not self.irssi_user:
            self.response.status = "401 Unauthorized"
            return False

        if not self.validate_params(self.data, paramRequirements):
            self.response.status = "400 Bad Request"
            return False
        return True
コード例 #3
0
ファイル: controllers.py プロジェクト: murgo/IrssiNotifier
    def get(self):
        logging.debug("WebController.get()")
        user = login.get_irssi_user(self.request.params)

        tokens = []
        irssi_script_version = 0
        registration_date = 'Aeons ago'
        last_notification_time = 'Upgrade to Plus to see'
        notification_count_since_licensed = 'Upgrade to Plus to see'
        license_type = 'Free'
        irssi_working = False
        license_timestamp = 0

        if user is not None:
            tokens = dao.get_gcm_tokens_for_user(user)

            for token in tokens:
                if token.registration_date is not None:
                    token.registration_date_string = token.registration_date
                else:
                    token.registration_date_string = 'Yesterday?'

            if user.license_timestamp is not None:
                license_type = 'Plus'
                license_timestamp = user.license_timestamp

                if user.last_notification_time is not None:
                    last_notification_time = user.last_notification_time
                else:
                    last_notification_time = 'Never'

                if user.notification_count_since_licensed is not None:
                    notification_count_since_licensed = user.notification_count_since_licensed
                else:
                    notification_count_since_licensed = 0

            irssi_script_version = user.irssi_script_version
            if irssi_script_version is None:
                irssi_script_version = 0

            if user.registration_date is not None:
                registration_date = user.registration_date

            if user.last_notification_time is not None:
                irssi_working = True

        template_values = {
            'user': user,
            'tokens': tokens,
            'token_count': len(tokens),
            'logged_in': user is not None,
            'login_url': users.create_login_url("#profile").replace("&", "&"),
            'logout_url': users.create_logout_url("").replace("&", "&"),
            'irssi_working': irssi_working,
            'irssi_latest': irssi_script_version >= LatestScriptVersion,
            'registration_date': registration_date,
            'last_notification_time': last_notification_time,
            'notification_count_since_licensed': notification_count_since_licensed,
            'license_type': license_type,
            'license_timestamp': license_timestamp
        }

        template = jinja_environment.get_template('html/index.html')
        self.response.out.write(template.render(template_values))
コード例 #4
0
    def get(self):
        logging.debug("WebController.get()")
        user = login.get_irssi_user(self.request.params)

        tokens = []
        irssi_script_version = 0
        registration_date = 'Aeons ago'
        last_notification_time = 'Upgrade to Plus to see'
        notification_count_since_licensed = 'Upgrade to Plus to see'
        license_type = 'Free'
        irssi_working = False
        license_timestamp = 0

        if user is not None:
            tokens = dao.get_gcm_tokens_for_user(user)

            for token in tokens:
                if token.registration_date is not None:
                    token.registration_date_string = token.registration_date
                else:
                    token.registration_date_string = 'Yesterday?'

            if user.license_timestamp is not None:
                license_type = 'Plus'
                license_timestamp = user.license_timestamp

                if user.last_notification_time is not None:
                    last_notification_time = user.last_notification_time
                else:
                    last_notification_time = 'Never'

                if user.notification_count_since_licensed is not None:
                    notification_count_since_licensed = user.notification_count_since_licensed
                else:
                    notification_count_since_licensed = 0

            irssi_script_version = user.irssi_script_version
            if irssi_script_version is None:
                irssi_script_version = 0

            if user.registration_date is not None:
                registration_date = user.registration_date

            if user.last_notification_time is not None:
                irssi_working = True

        template_values = {
            'user': user,
            'tokens': tokens,
            'token_count': len(tokens),
            'logged_in': user is not None,
            'login_url':
            users.create_login_url("#profile").replace("&", "&"),
            'logout_url': users.create_logout_url("").replace("&", "&"),
            'irssi_working': irssi_working,
            'irssi_latest': irssi_script_version >= LatestScriptVersion,
            'registration_date': registration_date,
            'last_notification_time': last_notification_time,
            'notification_count_since_licensed':
            notification_count_since_licensed,
            'license_type': license_type,
            'license_timestamp': license_timestamp
        }

        template = jinja_environment.get_template('html/index.html')
        self.response.out.write(template.render(template_values))