~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/translations/browser/potemplate.py

  • Committer: Henning Eggers
  • Date: 2011-06-07 10:28:11 UTC
  • mto: This revision was merged to the branch mainline in revision 13176.
  • Revision ID: henning@canonical.com-20110607102811-b0pjwhm4zf95kf4j
Fix the bug.

Show diffs side-by-side

added added

removed removed

Lines of Context:
604
604
                self.setFieldError(
605
605
                    'sourcepackagename',
606
606
                    "Source package already has a template with "
607
 
                    "the same name.")
 
607
                    "that same name.")
608
608
            elif productseries_changed:
609
609
                self.setFieldError(
610
610
                    'productseries',
611
 
                    "Series already has a template with the same name.")
612
 
            else:
 
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.")
614
614
 
615
 
    def validateDomain(self, domain, similar_templates):
616
 
        if domain == self.context.translation_domain:
617
 
            # Not changed.
618
 
            return
619
 
 
 
615
    def validateDomain(self, domain, similar_templates,
 
616
                       sourcepackage_changed, productseries_changed):
620
617
        other_template = similar_templates.getPOTemplateByTranslationDomain(
621
618
            domain)
622
619
        if other_template is not None:
623
 
            self.setFieldError(
624
 
                'translation_domain', "Domain is already in use.")
625
 
            return
 
620
            if sourcepackage_changed:
 
621
                self.setFieldError(
 
622
                    'sourcepackagename',
 
623
                    "Source package already has a template with "
 
624
                    "that same domain.")
 
625
            elif productseries_changed:
 
626
                self.setFieldError(
 
627
                    'productseries',
 
628
                    "Series already has a template with that same domain.")
 
629
            elif domain != self.context.translation_domain:
 
630
                self.setFieldError(
 
631
                    'translation_domain', "Domain is already in use.")
626
632
 
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)
 
668
        self.validateDomain(
 
669
            data.get('translation_domain'), similar_templates,
 
670
            sourcepackage_changed, productseries_changed)
663
671
 
664
672
 
665
673
class POTemplateExportView(BaseExportView):