Esempio n. 1
0
    def post(self, *args, **kwargs):
        schema = self.get_object()

        if 'cancel' in self.request.POST:
            return redirect("coding schema-details", self.project.id,
                            schema.id)

        # No, copy as requested
        new_schema = CodingSchema(name=self.request.POST.get("name"),
                                  description=schema.description,
                                  isarticleschema=schema.isarticleschema,
                                  subsentences=schema.subsentences,
                                  highlight_language=schema.highlight_language,
                                  project=self.project)

        new_schema.save()

        for field in schema.fields.all():
            field.id = None
            field.codingschema = new_schema
            field.save()

        self.request.session["notification"] = (
            "Copied coding schema. "
            "You can return to the overview using the 'Coding Schemas' link above"
        )
        return redirect("coding schema-details", self.project.id,
                        new_schema.id)
Esempio n. 2
0
def name_schema(request, schema, project):
    """
    User confirmed copying schema, ask for a name to give.
    """
    if request.POST:
        if 'cancel' in request.POST:
            return redirect("project-schema", project.id, schema.id)

        # No, copy as requested
        new_schema = CodingSchema(name=request.POST.get("name"),
                                  description=schema.description,
                                  isnet=schema.isnet,
                                  isarticleschema=schema.isarticleschema,
                                  quasisentences=schema.quasisentences,
                                  project=project)

        new_schema.save()

        for field in schema.fields.all():
            field.id = None
            field.codingschema = new_schema
            field.save()

        request.session["schema_%s_is_new" % new_schema.id] = True
        return redirect("project-schema", project.id, new_schema.id)

    return table_view(request,
                      project,
                      None,
                      'codingschemas',
                      template="navigator/project/name_schema.html",
                      schema=schema)