604
604
self.setFieldError(
605
605
'sourcepackagename',
606
606
"Source package already has a template with "
608
608
elif productseries_changed:
609
609
self.setFieldError(
611
"Series already has a template with the same name.")
611
"Series already has a template with that same name.")
612
elif name != self.context.name:
613
613
self.setFieldError('name', "Name is already in use.")
615
def validateDomain(self, domain, similar_templates):
616
if domain == self.context.translation_domain:
615
def validateDomain(self, domain, similar_templates,
616
sourcepackage_changed, productseries_changed):
620
617
other_template = similar_templates.getPOTemplateByTranslationDomain(
622
619
if other_template is not None:
624
'translation_domain', "Domain is already in use.")
620
if sourcepackage_changed:
623
"Source package already has a template with "
625
elif productseries_changed:
628
"Series already has a template with that same domain.")
629
elif domain != self.context.translation_domain:
631
'translation_domain', "Domain is already in use.")
627
633
def validate(self, data):
628
634
super(POTemplateAdminView, self).validate(data)
659
665
self.validateName(
660
666
data.get('name'), similar_templates,
661
667
sourcepackage_changed, productseries_changed)
662
self.validateDomain(data.get('translation_domain'), similar_templates)
669
data.get('translation_domain'), similar_templates,
670
sourcepackage_changed, productseries_changed)
665
673
class POTemplateExportView(BaseExportView):