Beispiel #1
0
    def auto_tag(self):
        """Apply tags to myself that are implied by my metadata.

        You don't need to call save on the question after this.

        """
        to_add = self.product.get('tags', []) + self.category.get('tags', [])

        version = self.metadata.get('ff_version', '')
        if version in product_details.firefox_history_development_releases or \
           version in product_details.firefox_history_stability_releases or \
           version in product_details.firefox_history_major_releases:
            to_add.append('Firefox %s' % version)
            tenths = _tenths_version(version)
            if tenths:
                to_add.append('Firefox %s' % tenths)

        self.tags.add(*to_add)

        # Add a tag for the OS if it already exists as a tag:
        os = self.metadata.get('os')
        if os:
            try:
                add_existing_tag(os, self.tags)
            except Tag.DoesNotExist:
                pass
Beispiel #2
0
 def test_add_existing_no_such_tag(self):
     """Assert add_existing_tag doesn't work when the tag doesn't exist."""
     add_existing_tag('nonexistent tag', self.untagged_question.tags)
Beispiel #3
0
 def test_add_existing_case_insensitive(self):
     """Assert add_existing_tag works case-insensitively."""
     add_existing_tag('LEMON', self.untagged_question.tags)
     tags_eq(self.untagged_question, [u'lemon'])