~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
        """
132
132
        schema, netloc, path, parameters, query, fragment = (
133
133
            urlparse(str(request.URL)))
134
 
 
135
134
        # For safety, delete the start and batch variables, if they
136
135
        # appear in the URL. The situation in which 'start' appears
137
136
        # today is when the alternative language form is posted back and
336
335
            UTC = pytz.timezone('UTC')
337
336
            self.lock_timestamp = datetime.datetime.now(UTC)
338
337
 
339
 
 
340
338
        # The batch navigator needs to be initialized early, before
341
339
        # _submitTranslations is called; the reason for this is that
342
340
        # _submitTranslations, in the case of no errors, redirects to
746
744
        msgset_ID_LANGCODE_translation_ = 'msgset_%d_%s_translation_' % (
747
745
            potmsgset_ID, language_code)
748
746
 
 
747
        msgset_ID_LANGCODE_translation_GREATER_PLURALFORM_new = '%s%d_new' % (
 
748
            msgset_ID_LANGCODE_translation_,
 
749
            TranslationConstants.MAX_PLURAL_FORMS)
 
750
        if msgset_ID_LANGCODE_translation_GREATER_PLURALFORM_new in form:
 
751
            # The plural form translation generation rules created too many
 
752
            # fields, or the form was hacked.
 
753
            raise AssertionError(
 
754
                'More than %d plural forms were submitted!'
 
755
                % TranslationConstants.MAX_PLURAL_FORMS)
 
756
 
749
757
        # Extract the translations from the form, and store them in
750
758
        # self.form_posted_translations. We try plural forms in turn,
751
759
        # starting at 0.
822
830
            if store:
823
831
                self.form_posted_translations_has_store_flag[
824
832
                    potmsgset].append(pluralform)
825
 
        else:
826
 
            raise AssertionError('More than %d plural forms were submitted!'
827
 
                                 % TranslationConstants.MAX_PLURAL_FORMS)
828
833
 
829
834
    def _observeTranslationUpdate(self, potmsgset):
830
835
        """Observe that a translation was updated for the potmsgset.
1109
1114
            other_translation = self.getOtherTranslation(index)
1110
1115
            shared_translation = self.getSharedTranslation(index)
1111
1116
            submitted_translation = self.getSubmittedTranslation(index)
1112
 
            if (submitted_translation is None and
1113
 
                self.user_is_official_translator):
1114
 
                # We don't have anything to show as the submitted translation
1115
 
                # and the user is the official one. We prefill the 'New
1116
 
                # translation' field with the current translation.
1117
 
                translation = current_translation
1118
1117
            is_multi_line = (count_lines(current_translation) > 1 or
1119
1118
                             count_lines(submitted_translation) > 1 or
1120
1119
                             count_lines(self.singular_text) > 1 or