Ejemplo n.º 1
0
 def test_activate_password(self):
     # Hack to install our create_user method.
     user_class = get_user_model()
     user_class.objects = ActivatedUserManager()
     user_class.objects.model = user_class
     user = get_user_model().objects.create_user(REGISTRATION_EMAIL,
                                                 email=REGISTRATION_EMAIL,
                                                 is_active=False)
     client = Client()
     response = client.get(reverse('registration_activate',
                                   args=(user.contact.verification_key, )),
                           follow=True)
     # pylint: disable=maybe-no-member
     self.assertTrue(response.status_code == 200)
     self.assertTrue(
         re.match(
             r'/activate/(?P<verification_key>%s)/password/(?P<token>.+)/$'
             % signup_settings.EMAIL_VERIFICATION_PAT,
             response.redirect_chain[-1][0]))
Ejemplo n.º 2
0
def environment(**options):
    from django.contrib.auth import get_user_model
    from signup.models import ActivatedUserManager

    # Hack to install our create_user method.
    user_class = get_user_model()
    user_class.objects = ActivatedUserManager()
    user_class.objects.model = user_class

    assets_env = get_env()
    # If we don't force ``auto_reload`` to True, in DEBUG=0, the templates
    # would only be compiled on the first edit.
    options.update({'auto_reload': True})
    if 'loader' in options:
        options['loader'] = import_string(options['loader'])(
            get_template_search_path())
    env = DjaoappEnvironment(extensions=[AssetsExtension], **options)
    # Generic filters to render pages
    env.filters['asset'] = multitier.templatetags.multitier_tags.asset
    env.filters['absolute_uri'] = \
        multitier.templatetags.multitier_tags.absolute_uri
    env.filters['djasset'] = djaoapp.templatetags.djaoapp_tags.djasset
    env.filters['host'] = deployutils_extratags.host
    env.filters['is_authenticated'] = \
        djaoapp.templatetags.djaoapp_tags.is_authenticated
    env.filters['is_checkbox'] = djaoapp.templatetags.djaoapp_tags.is_checkbox
    env.filters['is_radio'] = djaoapp.templatetags.djaoapp_tags.is_radio
    env.filters['is_textarea'] = djaoapp.templatetags.djaoapp_tags.is_textarea
    env.filters['iterfields'] = djaoapp.templatetags.djaoapp_tags.iterfields
    env.filters['messages'] = djaoapp.templatetags.djaoapp_tags.messages
    env.filters['no_cache'] = djaoapp.templatetags.djaoapp_tags.no_cache
    env.filters['pluralize'] = djaoapp.templatetags.djaoapp_tags.pluralize
    env.filters['site_prefixed'] = \
        multitier.templatetags.multitier_tags.site_prefixed
    env.filters['to_json'] = deployutils_extratags.to_json

    # Standard site pages
    env.filters['site_printable_name'] = \
        djaoapp.templatetags.djaoapp_tags.site_printable_name
    env.filters['url_app'] = djaoapp.templatetags.djaoapp_tags.url_app
    env.filters['url_contact'] = djaoapp.templatetags.djaoapp_tags.url_contact
    env.filters['url_home'] = djaoapp.templatetags.djaoapp_tags.url_home
    env.filters['url_login'] = djaoapp.templatetags.djaoapp_tags.url_login
    env.filters['url_logout'] = djaoapp.templatetags.djaoapp_tags.url_logout
    env.filters['url_pricing'] = djaoapp.templatetags.djaoapp_tags.url_pricing
    env.filters['url_profile'] = djaoapp.templatetags.djaoapp_tags.url_profile
    env.filters['url_register'] \
        = djaoapp.templatetags.djaoapp_tags.url_register
    # Specific to SaaS
    env.filters['isoformat'] = saas.templatetags.saas_tags.isoformat
    env.filters['short_date'] = saas.templatetags.saas_tags.short_date
    env.filters['humanize_money'] = saas.templatetags.saas_tags.humanize_money
    env.filters[
        'humanize_period'] = saas.templatetags.saas_tags.humanize_period
    env.filters['date_in_future'] = saas.templatetags.saas_tags.date_in_future
    env.filters['md'] = saas.templatetags.saas_tags.md
    env.filters['describe'] = saas.templatetags.saas_tags.describe

    if settings.DEBUG:
        env.filters['query_parameters'] = \
            djaoapp.templatetags.djaoapp_tags.query_parameters
        env.filters['request_body_parameters'] = \
            djaoapp.templatetags.djaoapp_tags.request_body_parameters
        env.filters['not_key'] = \
            djaoapp.templatetags.djaoapp_tags.not_key
        env.filters['schema_href'] = \
            djaoapp.templatetags.djaoapp_tags.schema_href
        env.filters['schema_name'] = \
            djaoapp.templatetags.djaoapp_tags.schema_name
        env.filters['addslashes'] = django.template.defaultfilters.addslashes
        env.globals.update({
            'FEATURES_DEBUG': settings.FEATURES_DEBUG,
            'VUEJS': (settings.JS_FRAMEWORK == 'vuejs'),
            'DATETIME_FORMAT': "MMM dd, yyyy",
            'url': reverse,
            'cycle': django.template.defaulttags.cycle
        })
    env.assets_environment = assets_env
    return env