Exemplo n.º 1
0
def require_module(module):
    """
    Generates a dumped dictionary representation of a require module appropriate for
    embedding in a javascript template

    If the module is configured in REQUIRE_STANDALONE_MODULES, and REQUIRE_DEBUG is False, then
    then the standalone built version of the module will be loaded instead, bypassing require.js
    for extra load performance.

    This is adapted from the corresponding template tag in django-require, which is available
    under the following license:

        Copyright (c) 2009, David Hall.
        All rights reserved.

        Redistribution and use in source and binary forms, with or without modification,
        are permitted provided that the following conditions are met:

            1. Redistributions of source code must retain the above copyright notice,
               this list of conditions and the following disclaimer.

            2. Redistributions in binary form must reproduce the above copyright
               notice, this list of conditions and the following disclaimer in the
               documentation and/or other materials provided with the distribution.

            3. Neither the name of David Hall nor the names of its contributors may be
               used to endorse or promote products derived from this software without
               specific prior written permission.

        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
        ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
        ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    """
    if not require_settings.REQUIRE_DEBUG and module in require_settings.REQUIRE_STANDALONE_MODULES:
        return """{{src: '{module}' }}""".format(module=get_site_url(
            staticfiles_storage.url(
                resolve_require_module(
                    require_settings.REQUIRE_STANDALONE_MODULES[module]
                    ["out"]))), )
    return """{{src: '{src}', "data-main": '{module}' }}""".format(
        src=get_site_url(
            staticfiles_storage.url(
                resolve_require_url(require_settings.REQUIRE_JS))),
        module=get_site_url(
            staticfiles_storage.url(resolve_require_module(module))),
    )
Exemplo n.º 2
0
def require_module(module):
    """
    Generates a dumped dictionary representation of a require module appropriate for
    embedding in a javascript template

    If the module is configured in REQUIRE_STANDALONE_MODULES, and REQUIRE_DEBUG is False, then
    then the standalone built version of the module will be loaded instead, bypassing require.js
    for extra load performance.

    This is adapted from the corresponding template tag in django-require, which is available
    under the following license:

        Copyright (c) 2009, David Hall.
        All rights reserved.

        Redistribution and use in source and binary forms, with or without modification,
        are permitted provided that the following conditions are met:

            1. Redistributions of source code must retain the above copyright notice,
               this list of conditions and the following disclaimer.

            2. Redistributions in binary form must reproduce the above copyright
               notice, this list of conditions and the following disclaimer in the
               documentation and/or other materials provided with the distribution.

            3. Neither the name of David Hall nor the names of its contributors may be
               used to endorse or promote products derived from this software without
               specific prior written permission.

        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
        ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
        ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    """
    if not require_settings.REQUIRE_DEBUG and module in require_settings.REQUIRE_STANDALONE_MODULES:
        return """{{src: '{module}' }}""".format(
            module = get_site_url(staticfiles_storage.url(resolve_require_module(require_settings.REQUIRE_STANDALONE_MODULES[module]["out"]))),
        )
    return """{{src: '{src}', "data-main": '{module}' }}""".format(
        src = get_site_url(staticfiles_storage.url(resolve_require_url(require_settings.REQUIRE_JS))),
        module = get_site_url(staticfiles_storage.url(resolve_require_module(module))),
    )
Exemplo n.º 3
0
    def save(self):

        email = self.cleaned_data["email"]

        temp_key = generate_key(email)

        models.EmailConfirmation.objects.filter(user=self.user).delete()

        models.EmailConfirmation.objects.create(user=self.user,
                                                temp_key=temp_key,
                                                email=email)

        url = get_site_url(reverse('acct_confirm_email', args=(temp_key,)))

        ctx = {
            "user": self.user,
            "activate_url": url,
            "SITE_NAME": settings.SITE_NAME,
            'CONTACT_EMAIL': settings.CONTACT_EMAIL,
        }
        subject = render_to_string("account/email_confirmation_subject.txt",
                                   ctx)

        message = render_to_string("account/email_confirmation_message.txt",
                                   ctx)

        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [email])
Exemplo n.º 4
0
    def save(self):

        email = self.cleaned_data["email"]

        temp_key = generate_key(email)

        models.EmailConfirmation.objects.filter(user=self.user).delete()

        models.EmailConfirmation.objects.create(user=self.user,
                                                temp_key=temp_key,
                                                email=email)

        url = get_site_url(reverse('acct_confirm_email', args=(temp_key, )))

        ctx = {
            "user": self.user,
            "activate_url": url,
            "SITE_NAME": settings.SITE_NAME,
            'CONTACT_EMAIL': settings.CONTACT_EMAIL,
        }
        subject = render_to_string("account/email_confirmation_subject.txt",
                                   ctx)

        message = render_to_string("account/email_confirmation_message.txt",
                                   ctx)

        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [email])
Exemplo n.º 5
0
class LatestDataViews(ItemMixin, Feed):
    title = "Latest Data Views"
    description = "Latest Data Views"
    link = get_site_url()

    def items(self):
        u = AnonymousUser()
        filter = PermissionsRegistry.get_filter('exhibit.can_view', u)

        return PublishedExhibit.objects.filter(filter).order_by(
            '-created')[:10]
Exemplo n.º 6
0
    def generate_context(self, request, form, *args, **kwargs):
        username = request.user.username
        profile = reverse("profile_detail", kwargs={"username": username})
        profile = get_site_url(profile)
        system_name = "%s %s" % (settings.SITE_NAME, settings.SITE_NAME_STATUS)

        info = (settings.SITE_NAME, viewshare_version, get_akara_version(), AKARA_URL_PREFIX)
        system_info = "%s - Viewshare %s - Akara %s - Akara Root %s" % info

        return dict(
            form.cleaned_data,
            **{
                "submitting_user_name": request.user.username,
                "submitting_user_profile": profile,
                "system_name": system_name,
                "system_link": get_site_url(),
                "system_info": system_info,
                "user_agent": request.META["HTTP_USER_AGENT"],
            }
        )
Exemplo n.º 7
0
    def generate_context(self, request, form, *args, **kwargs):
        username = request.user.username
        profile = reverse('profile_detail', kwargs={'username': username})
        profile = get_site_url(profile)
        system_name = '%s %s' % (settings.SITE_NAME, settings.SITE_NAME_STATUS)

        info = (
            settings.SITE_NAME,
            viewshare_version,
            get_akara_version(),
            AKARA_URL_PREFIX,
        )
        system_info = '%s - Viewshare %s - Akara %s - Akara Root %s' % info

        return dict(
            form.cleaned_data, **{
                'submitting_user_name': request.user.username,
                'submitting_user_profile': profile,
                'system_name': system_name,
                'system_link': get_site_url(),
                'system_info': system_info,
                'user_agent': request.META["HTTP_USER_AGENT"]
            })
Exemplo n.º 8
0
 def link(self, obj):
     return get_site_url(reverse("profile_detail", kwargs={'username':
                 obj.username}))
Exemplo n.º 9
0
 def link(self, obj):
     return get_site_url(
         reverse("profile_detail", kwargs={'username': obj.username}))
Exemplo n.º 10
0
def site_url(path="/"):
    """
    Outputs the fully qualified URL for a provided path
    """
    return str(get_site_url(path))