Exemplo n.º 1
0
    def get(self):
        name = self.get_argument('name')
        project = Project.get_plain(name)

        if project:
            self.write(project.to_dict())
        else:
            raise HTTPError(404, reason='Project not found')
Exemplo n.º 2
0
    def get(self):
        name = self.get_argument('name')
        project = Project.get_plain(name)

        if project:
            self.write(project.to_dict())
        else:
            raise HTTPError(404, reason='Project not found')
Exemplo n.º 3
0
    def get(self, project_id):
        project = Project.get_plain(project_id)
        form = ProjectSettingsForm(**project.to_dict())

        self.render(
            'admin/project/shortener_settings.html',
            project_id=project_id, form=form,
        )
Exemplo n.º 4
0
 def get(self, project_id):
     project = Project.get_plain(project_id)
     enable_form = QueueEnableForm(data=self.get_enable_form(project))
     form = QueueSettingsForm(data=self.get_queue_settings_form(project))
     self.render('admin/project/queue_settings.html',
                 project_id=project_id,
                 lower_shortcode=project.lower_shortcode(),
                 form=form,
                 enable_form=enable_form)
Exemplo n.º 5
0
    def get(self, project_id):
        project = Project.get_plain(project_id)
        form = ProjectSettingsForm(**project.to_dict())

        self.render(
            'admin/project/shortener_settings.html',
            project_id=project_id,
            form=form,
        )
Exemplo n.º 6
0
 def get(self, project_id):
     project = Project.get_plain(project_id)
     enable_form = QueueEnableForm(data=self.get_enable_form(project))
     form = QueueSettingsForm(data=self.get_queue_settings_form(project))
     self.render(
         'admin/project/queue_settings.html',
         project_id=project_id,
         lower_shortcode=project.lower_shortcode(),
         form=form,
         enable_form=enable_form
     )
Exemplo n.º 7
0
    def post(self, name):
        project = Project.get_plain(name)
        enable_form = QueueEnableForm(data=self.get_enable_form(project))
        form = QueueSettingsForm(data=self.get_queue_settings_form(project))
        lower_shortcode = project.lower_shortcode()

        message = None
        action = self.get_argument('action', None)

        if action == 'enable':
            enable_form = QueueEnableForm(self.request.arguments)
            if enable_form.validate():
                with Project.get_session_object(name) as project:
                    project.enabled = enable_form.enabled.data
                    logger.info('Project %s enabled=%s',
                                name, project.enabled)
                    message = ('Enabled' if project.enabled else 'Disabled')
            else:
                message = 'Error in Queue Enable Form.'

        elif action == 'autoqueue':
            form = QueueSettingsForm(self.request.arguments)
            if form.validate():
                with Project.get_session_object(name) as project:
                    project.autoqueue = form.autoqueue.data
                    project.num_count_per_item = form.num_count_per_item.data
                    project.max_num_items = form.max_num_items.data
                    project.lower_sequence_num = form.lower_sequence_num.data or 0
                    project.autorelease_time = form.autorelease_time.data * 60 or 0

                    lower_shortcode = project.lower_shortcode()

                logger.debug('Project %s queue settings changed.', name)
                message = 'Settings saved.'
            else:
                message = 'Error in Auto Queue Form.'
        else:
            message = 'Error: unrecognized action argument.'

        Budget.calculate_budgets()

        self.render(
            'admin/project/queue_settings.html',
            project_name=name,
            lower_shortcode=lower_shortcode,
            form=form,
            enable_form=enable_form,
            message=message
        )
Exemplo n.º 8
0
    def get(self, name):
        project = Project.get_plain(name)
        form = ProjectSettingsForm(
            alphabet=project.alphabet,
            banned_codes=project.banned_codes,
            body_regex=project.body_regex,
            method=project.method,
            min_version=project.min_version,
            min_client_version=project.min_client_version,
            no_redirect_codes=project.no_redirect_codes,
            redirect_codes=project.redirect_codes,
            request_delay=project.request_delay,
            url_template=project.url_template,
            unavailable_codes=project.unavailable_codes,
        )

        self.render("admin/project/shortener_settings.html", project_name=name, form=form)
Exemplo n.º 9
0
    def post(self, project_id):
        project = Project.get_plain(project_id)
        enable_form = QueueEnableForm(data=self.get_enable_form(project))
        form = QueueSettingsForm(data=self.get_queue_settings_form(project))
        lower_shortcode = project.lower_shortcode()

        message = None
        action = self.get_argument('action', None)

        if action == 'enable':
            enable_form = QueueEnableForm(self.request.arguments)
            if enable_form.validate():
                with Project.get_session_object(project_id) as project:
                    project.enabled = enable_form.enabled.data
                    logger.info(self.user_audit_text('Project %s enabled=%s'),
                                project_id, project.enabled)
                    message = ('Enabled' if project.enabled else 'Disabled')
            else:
                message = 'Error in Queue Enable Form.'

        elif action == 'autoqueue':
            form = QueueSettingsForm(self.request.arguments)
            if form.validate():
                with Project.get_session_object(project_id) as project:
                    form.populate_obj(project)
                    project.lower_sequence_num = form.lower_sequence_num.data or 0
                    project.autorelease_time = form.autorelease_time.data * 60 or 0

                    lower_shortcode = project.lower_shortcode()

                logger.debug('Project %s queue settings changed.', project_id)
                message = 'Settings saved.'
            else:
                message = 'Error in Auto Queue Form.'
        else:
            message = 'Error: unrecognized action argument.'

        Budget.calculate_budgets()

        self.render('admin/project/queue_settings.html',
                    project_id=project_id,
                    lower_shortcode=lower_shortcode,
                    form=form,
                    enable_form=enable_form,
                    message=message)
Exemplo n.º 10
0
    def post(self, name):
        project = Project.get_plain(name)
        enable_form = QueueEnableForm(data=self.get_enable_form(project))
        form = QueueSettingsForm(data=self.get_queue_settings_form(project))

        message = None
        action = self.get_argument("action", None)

        if action == "enable":
            enable_form = QueueEnableForm(self.request.arguments)
            if enable_form.validate():
                with Project.get_session_object(name) as project:
                    project.enabled = enable_form.enabled.data
                    logger.info("Project %s enabled=%s", name, project.enabled)
            else:
                message = "Error."

        elif action == "autoqueue":
            form = QueueSettingsForm(self.request.arguments)
            if form.validate():
                with Project.get_session_object(name) as project:
                    project.autoqueue = form.autoqueue.data
                    project.num_count_per_item = form.num_count_per_item.data
                    project.max_num_items = form.max_num_items.data
                    project.lower_sequence_num = form.lower_sequence_num.data or 0
                    project.autorelease_time = form.autorelease_time.data * 60 or 0

                logger.debug("Project %s queue settings changed.", name)
                message = "Settings saved."
            else:
                message = "Error."
        else:
            message = "Error."

        Budget.calculate_budgets()

        self.render(
            "admin/project/queue_settings.html", project_name=name, form=form, enable_form=enable_form, message=message
        )
Exemplo n.º 11
0
 def get(self, name):
     project = Project.get_plain(name)
     enable_form = QueueEnableForm(data=self.get_enable_form(project))
     form = QueueSettingsForm(data=self.get_queue_settings_form(project))
     self.render("admin/project/queue_settings.html", project_name=name, form=form, enable_form=enable_form)