Esempio n. 1
0
def get_terms(kwargs):
    """Checks URL parameters for slug and/or version to pull the right TermsAndConditions object"""
    slug = kwargs.get("slug", DEFAULT_TERMS_SLUG)

    if kwargs.get("version"):
        terms = TermsAndConditions.objects.get(slug=slug, version_number=kwargs.get("version"))
    else:
        terms = TermsAndConditions.get_active(slug)
    return terms
Esempio n. 2
0
def get_terms(kwargs):
    """Checks URL parameters for slug and/or version to pull the right TermsAndConditions object"""
    slug = kwargs.get("slug", DEFAULT_TERMS_SLUG)

    if kwargs.get("version"):
        terms = TermsAndConditions.objects.get(
            slug=slug, version_number=kwargs.get("version"))
    else:
        terms = TermsAndConditions.get_active(slug)
    return terms
Esempio n. 3
0
    def test_terms_and_conditions_models(self):
        """Various tests of the TermsAndConditions Module"""

        # Testing Direct Assignment of Acceptance
        UserTermsAndConditions.objects.create(user=self.user1, terms=self.terms1)
        UserTermsAndConditions.objects.create(user=self.user2, terms=self.terms3)

        self.assertEquals(1.0, self.user1.userterms.get().terms.version_number)
        self.assertEquals(1.5, self.user2.userterms.get().terms.version_number)

        self.assertEquals('user1', self.terms1.users.all()[0].username)

        # Testing the get_active static method of TermsAndConditions
        self.assertEquals(2.0, TermsAndConditions.get_active(slug='site-terms').version_number)
        self.assertEquals(1.5, TermsAndConditions.get_active(slug='contrib-terms').version_number)

        # Testing the agreed_to_latest static method of TermsAndConditions
        self.assertEquals(False, TermsAndConditions.agreed_to_latest(user=self.user1, slug='site-terms'))
        self.assertEquals(True, TermsAndConditions.agreed_to_latest(user=self.user2, slug='contrib-terms'))

        # Testing the unicode method of TermsAndConditions
        self.assertEquals('site-terms-2.00', str(TermsAndConditions.get_active(slug='site-terms')))
        self.assertEquals('contrib-terms-1.50', str(TermsAndConditions.get_active(slug='contrib-terms')))
Esempio n. 4
0
    def test_terms_and_conditions_models(self):
        """Various tests of the TermsAndConditions Module"""

        # Testing Direct Assignment of Acceptance
        UserTermsAndConditions.objects.create(user=self.user1, terms=self.terms1)
        UserTermsAndConditions.objects.create(user=self.user2, terms=self.terms3)

        self.assertEquals(1.0, self.user1.userterms.get().terms.version_number)
        self.assertEquals(1.5, self.user2.userterms.get().terms.version_number)

        self.assertEquals('user1', self.terms1.users.all()[0].username)

        # Testing the get_active static method of TermsAndConditions
        self.assertEquals(2.0, TermsAndConditions.get_active(slug='site-terms').version_number)
        self.assertEquals(1.5, TermsAndConditions.get_active(slug='contrib-terms').version_number)

        # Testing the agreed_to_latest static method of TermsAndConditions
        self.assertEquals(False, TermsAndConditions.agreed_to_latest(user=self.user1, slug='site-terms'))
        self.assertEquals(True, TermsAndConditions.agreed_to_latest(user=self.user2, slug='contrib-terms'))

        # Testing the unicode method of TermsAndConditions
        self.assertEquals('site-terms-2.00', str(TermsAndConditions.get_active(slug='site-terms')))
        self.assertEquals('contrib-terms-1.50', str(TermsAndConditions.get_active(slug='contrib-terms')))