Beispiel #1
0
    def get_code(self, code_id):
        """Get code with id `code_id`. Uses cache if possible."""
        if self.cached:
            if code_id in self._codes:
                return self._codes[code_id]
            raise Code.DoesNotExist()

        try:
            return self.codebookcodes.select_related("code").get(code_id=code_id).code
        except CodebookCode.DoesNotExist:
            raise Code.DoesNotExist()
Beispiel #2
0
    def create_code(self, label, language, parent=None, **kargs):
        """
        Convenience method to create a new code with given language:label,
        and add it to this codebook under the optional parent
        """

        return self.add_code(Code.create(label, language), parent=parent, **kargs)
Beispiel #3
0
    def create_code(self, label, language, parent=None, **kargs):
        """
        Convenience method to create a new code with given language:label,
        and add it to this codebook under the optional parent
        """

        return self.add_code(Code.create(label, language), parent=parent, **kargs)
Beispiel #4
0
 def save(self):
     code = Code.create(label=self.cleaned_data['label'], language=self.cleaned_data['language'])
     self.cleaned_data['codebook'].add_code(code, self.cleaned_data.get('parent'))
Beispiel #5
0
 def save(self):
     code = Code.create(label=self.cleaned_data['label'],
                        language=self.cleaned_data['language'])
     self.cleaned_data['codebook'].add_code(code,
                                            self.cleaned_data.get('parent'))