<s> from django . core . exceptions import ValidationError <EOL> from django . db import models <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from ralph . attachments . helpers import get_file_path <EOL> from ralph . lib . mixins . models import NamedMixin , TimeStampMixin <EOL> def get_report_file_path ( instance , filename ) : <EOL> return get_file_path ( <EOL> instance , filename , default_dir = '<STR_LIT>' <EOL> ) <EOL> class Report ( NamedMixin , TimeStampMixin , models . Model ) : <EOL> pass <EOL> class ReportLanguage ( NamedMixin , TimeStampMixin , models . Model ) : <EOL> default = models . BooleanField ( ) <EOL> def clean ( self ) : <EOL> default_qs = self . __class__ . objects . filter ( default = True ) <EOL> if self . pk : <EOL> default_qs = default_qs . exclude ( pk = self . pk ) <EOL> if self . default and default_qs . count ( ) > <NUM_LIT:0> : <EOL> raise ValidationError ( _ ( '<STR_LIT>' ) ) <EOL> class ReportTemplate ( TimeStampMixin , models . Model ) : <EOL> template = models . FileField ( <EOL> upload_to = get_report_file_path , <EOL> blank = False , <EOL> ) <EOL> language = models . ForeignKey ( ReportLanguage ) <EOL> default = models . BooleanField ( ) <EOL> report = models . ForeignKey ( <EOL> Report , <EOL> related_name = '<STR_LIT>' , <EOL> ) <EOL> class Meta : <EOL> unique_together = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' . format ( self . template , self . language ) <EOL> @ property <EOL> def name ( self ) : <EOL> return self . report . name </s>
