def referenced_ruleset_widget(node, kw): view = kw['view'] query = "type_name == 'RuleSet'" values = [('', _("<Select>"))] for obj in view.catalog_query(query, resolve = True, sort_index = 'sortable_title'): values.append((obj.uid, "%s (%s)" % (obj.title, resource_path(obj)))) return deform.widget.SelectWidget(values = values)
def referenced_section_widget(node, kw): context = kw['context'] values = [('', _("<Select>"))] survey = find_interface(context, ISurvey) for obj in survey.values(): if ISurveySection.providedBy(obj): values.append((obj.uid, obj.title)) return deform.widget.SelectWidget(values = values)
def save_success(self, appstruct): choices = self.question.get_choices(self.request.locale_name) for choice in choices: if choice.cluster not in appstruct: raise HTTPForbidden("Saved data did not contain correct references to the choice: %r" % choice) for choice in choices: self.context.set_choice_score(self.question, choice, appstruct[choice.cluster]) self.flash_messages.add(_("Saved")) return HTTPFound(location=self.request.resource_url(self.context, "view"))
def save_success(self, appstruct): choices = self.question_type.get_choices(self.request.locale_name) for choice in choices: if choice.cluster not in appstruct: raise HTTPForbidden("Saved data did not contain correct references to the choice: %r" % choice) questions = tuple(self.request.resolve_docids(self.get_question_docids())) for question in questions: for choice in choices: self.context.set_choice_score(question, choice, appstruct[choice.cluster]) self.flash_messages.add(_("${count} questions updated.", mapping={"count": len(questions)})) return HTTPFound(location=self.request.resource_url(self.context, "view"))
def get_schema(self): schema = get_choice_values_schema(self.question_type, self.request) schema.title = _("Bulk edit ${count} question(s) at once", mapping={"count": len(self.get_question_docids())}) schema.description = _("bulk_edit_description", default="Warning: This will overwrite any previous values!") return schema
def question_type(self): qt = self.resolve_uid(self.request.GET.get("question_type", "")) if not qt: raise HTTPNotFound(_("Question type not found")) return qt
def buttons(self): return (deform.Button("filter", title=_("Filter")), self.button_cancel)
def get_schema(self): schema = get_choice_values_schema(self.question, self.request) schema.title = self.question.title schema.description = _("Individual scores for this question") return schema
def question(self): que = self.resolve_uid(self.request.GET.get("uid", "")) if not que: raise HTTPNotFound(_("Question not found")) return que
def tag_select_widget(node, kw): view = kw['view'] values = [('', _("All"))] tags = tuple(view.root.catalog['tags']._fwd_index.keys()) values.extend([(x, x) for x in tags]) return deform.widget.SelectWidget(values = values)
def add_nocount_option_to_choices(schema, event): schema.add(colander.SchemaNode(colander.Bool(), name = 'omit_from_score_count', title = _("Omit from score count"), default = False, missing = False))