Ejemplo n.º 1
0
def given_i_whant_to_set_a_group1_color_and_group2_image_group3(step, hex, rep, img):
    fimg   = open(path(img))
    is_rep = False if 'no' in rep else True
    data   = {'background_image': fimg, 
              'is_repeated'     : is_rep, 
              'background_color': hex}
    resp   =  world.client.post(world.store_design_url, data)
    assert resp.status_code == 302, \
        'Status code must be 302, not a %d' % resp.status_code 
    
    world.user = User.objects.get(username__exact='books')
    sd = world.user.store.shop_design
    assert os.path.basename(img).split('.')[0] in sd.background_image.url, \
                                    'There is no img at the model instance'
    assert sd.is_repeated == is_rep, 'Wrong the repeated trigger'
    assert sd.background_color == hex, 'Wrong color at the model instance'
Ejemplo n.º 2
0
    def test_confirm_delete(self):
        """Test the account deletion flow, including confirmation.

        A user should not be presented with a form/link that allows them to
        delete their account without a confirmation page. Once they access that
        page, they should be presented with a link to "go back" to their
        profile or to permanently delete their account.

        This test is abstracted away to a generic user deletion flow so
        we can test both non-vouched and vouched user's ability to delete
        their own profile.
        """
        for user, assertion in [(MOZILLIAN, MOZ_ASSERTION),
                     (PENDING, PND_ASSERTION)]:
            self._delete_flow(user, assertion)
        call(path('directory/devslapd/bin/x-rebuild'))
Ejemplo n.º 3
0
    def test_confirm_delete(self):
        """Test the account deletion flow, including confirmation.

        A user should not be presented with a form/link that allows them to
        delete their account without a confirmation page. Once they access that
        page, they should be presented with a link to "go back" to their
        profile or to permanently delete their account.

        This test is abstracted away to a generic user deletion flow so
        we can test both non-vouched and vouched user's ability to delete
        their own profile.
        """
        for user, assertion in [(MOZILLIAN, MOZ_ASSERTION),
                                (PENDING, PND_ASSERTION)]:
            self._delete_flow(user, assertion)
        call(path('directory/devslapd/bin/x-rebuild'))
Ejemplo n.º 4
0
from funfactory.urlresolvers import reverse
from jinja2 import Markup
from tower import ugettext_lazy as _lazy

from badges.models import Badge, BadgeInstance
from banners import COLOR_CHOICES
from shared.models import LocaleField, ModelBase
from shared.utils import absolutify, ugettext_locale as _locale


# L10n: Width and height are the width and height of an image.
SIZE = _lazy('%(width)sx%(height)s pixels')


BANNER_TEMPLATE_FILE = 'apps/banners/templates/banners/banner_template.html'
with open(path(BANNER_TEMPLATE_FILE)) as f:
    BANNER_TEMPLATE = f.read()


class Banner(Badge):
    """Badge consisting of an image link."""
    customize_view = 'banners.views.customize_banner'

    objects = CachingManager()

    def customize_url(self):
        return reverse('banners.customize', kwargs={'banner_pk': self.pk})


class BannerImageManager(CachingManager):
    def customize_values(self, **kwargs):
Ejemplo n.º 5
0
"""
:py:mod:`settings.initial` contains settings that IT will usually override.

The overrides can happen in :py:mod:`settings.initial_local`
(``settings/initial_local.py``).

Settings in :py:mod:`settings.default` and :py:mod:`settings.local` depend on
these.
"""

from funfactory.manage import path

#: This is the location of a share used on multiple nodes.  This is a perfect
#: place to store uploaded assets that are shared across webheads.
NETAPP_STORAGE = path('tmp')

#: Base URL for uploaded files. Could be a CDN.
UPLOAD_URL = '/media/uploads'
#: Should be MEDIA_ROOT in 1.4 but we are set in our ways.
UPLOAD_ROOT = path('media/uploads')

#: This is the base URL for the current instance of the site.
SITE_URL = 'http://mozillians.org'

try:
    from settings.initial_local import *
except ImportError:
    pass
Ejemplo n.º 6
0
from settings import initial as pre
from settings import MEDIA_URL

from apps.users.helpers import calculate_username

## Log settings
SYSLOG_TAG = "http_app_mozillians"
LOGGING = {
    'loggers': {
        'landing': {'level': logging.INFO},
        'phonebook': {'level': logging.INFO},
    },
}

## L10n
LOCALE_PATHS = [path('locale')]

# Accepted locales
PROD_LANGUAGES = ('ca', 'cs', 'de', 'en-US', 'es', 'hu', 'fr', 'ko', 'nl',
                  'pl', 'pt-BR', 'ru', 'sk', 'sl', 'sq', 'zh-TW', 'zh-CN',
                  'lt', 'ja')

# List of RTL locales known to this project. Subset of LANGUAGES.
RTL_LANGUAGES = ()  # ('ar', 'fa', 'fa-IR', 'he')

# For absoluate urls
PROTOCOL = "https://"
PORT = 443

## Media and templates.
TEMPLATE_DIRS = (path('apps/users/templates'), )
Ejemplo n.º 7
0
 def _migrations_path():
     """Return the absolute path to the migration script folder."""
     return manage.path('migrations')
Ejemplo n.º 8
0
from funfactory.manage import path
from funfactory import settings_base as base
from settings import initial as pre

## Log settings
SYSLOG_TAG = "http_app_mozillians"
LOGGING = {
    'loggers': {
        'landing': {'level': logging.INFO},
        'phonebook': {'level': logging.INFO},
    },
}

## L10n
LOCALE_PATHS = [path('locale')]

# Accepted locales
PROD_LANGUAGES = ('ca', 'cs', 'de', 'en-US', 'es', 'hu', 'fr', 'ko', 'nl',
                  'pl', 'pt-BR', 'ru', 'sk', 'sl', 'sq', 'zh-TW')

# List of RTL locales known to this project. Subset of LANGUAGES.
RTL_LANGUAGES = ()  # ('ar', 'fa', 'fa-IR', 'he')

# For absoluate urls
PROTOCOL = "https://"
PORT = 443

## Media and templates.
TEMPLATE_DIRS = base.TEMPLATE_DIRS + (path('apps/users/templates'), )
Ejemplo n.º 9
0
"""
:py:mod:`settings.initial` contains settings that IT will usually override.

The overrides can happen in :py:mod:`settings.initial_local`
(``settings/initial_local.py``).

Settings in :py:mod:`settings.default` and :py:mod:`settings.local` depend on
these.
"""

from funfactory.manage import path

#: This is the location of a share used on multiple nodes.  This is a perfect
#: place to store uploaded assets that are shared across webheads.
NETAPP_STORAGE = path('tmp')

#: Base URL for uploaded files. Could be a CDN.
UPLOAD_URL = '/media/uploads'

#: This is the base URL for the current instance of the site.
SITE_URL = 'http://mozillians.org'

try:
    from settings.initial_local import *
except ImportError:
    pass
Ejemplo n.º 10
0
    def setup_class(cls):
        import os

        os.environ["OPENLDAP_DB_PATH"] = "/home/vagrant/openldap-db"
        call(path("directory/devslapd/bin/x-rebuild"))
Ejemplo n.º 11
0
class AcceptedLocalesTest(test_utils.TestCase):
    """Test lazy evaluation of locale related settings.

    Verify that some localization-related settings are lazily evaluated based 
    on the current value of the DEV variable.  Depending on the value, 
    DEV_LANGUAGES or PROD_LANGUAGES should be used.

    """
    locale = path('project/locale')
    locale_bkp = path('project/locale_bkp')

    @classmethod
    def setup_class(cls):
        """Create a directory structure for locale/.

        Back up the existing project/locale/ directory and create the following
        hierarchy in its place:

            - project/locale/en-US/LC_MESSAGES
            - project/locale/fr/LC_MESSAGES
            - project/locale/templates/LC_MESSAGES
            - project/locale/empty_file

        Also, set PROD_LANGUAGES to ('en-US',).

        """
        if os.path.exists(cls.locale_bkp):
            raise Exception('A backup of locale/ exists at %s which might '
                            'mean that previous tests didn\'t end cleanly. '
                            'Skipping the test suite.' % cls.locale_bkp)
        cls.DEV = settings.DEV
        cls.PROD_LANGUAGES = settings.PROD_LANGUAGES
        cls.DEV_LANGUAGES = settings.DEV_LANGUAGES
        settings.PROD_LANGUAGES = ('en-US',)
        os.rename(cls.locale, cls.locale_bkp)
        for loc in ('en-US', 'fr', 'templates'):
            os.makedirs(os.path.join(cls.locale, loc, 'LC_MESSAGES'))
        open(os.path.join(cls.locale, 'empty_file'), 'w').close()

    @classmethod
    def teardown_class(cls):
        """Remove the testing locale/ dir and bring back the backup."""

        settings.DEV = cls.DEV
        settings.PROD_LANGUAGES = cls.PROD_LANGUAGES
        settings.DEV_LANGUAGES = cls.DEV_LANGUAGES
        shutil.rmtree(cls.locale)
        os.rename(cls.locale_bkp, cls.locale)

    def test_build_dev_languages(self):
        """Test that the list of dev locales is built properly.

        On dev instances, the list of accepted locales should correspond to 
        the per-locale directories in locale/.

        """
        settings.DEV = True
        assert (settings.DEV_LANGUAGES == ['en-US', 'fr'] or
                settings.DEV_LANGUAGES == ['fr', 'en-US']), \
                'DEV_LANGUAGES do not correspond to the contents of locale/.'

    def test_dev_languages(self):
        """Test the accepted locales on dev instances.

        On dev instances, allow locales defined in DEV_LANGUAGES.

        """
        settings.DEV = True
        # simulate the successful result of the DEV_LANGUAGES list 
        # comprehension defined in settings.
        settings.DEV_LANGUAGES = ['en-US', 'fr']
        assert settings.LANGUAGE_URL_MAP == {'en-us': 'en-US', 'fr': 'fr'}, \
               ('DEV is True, but DEV_LANGUAGES are not used to define the '
                'allowed locales.')

    def test_prod_languages(self):
        """Test the accepted locales on prod instances.

        On stage/prod instances, allow locales defined in PROD_LANGUAGES.

        """
        settings.DEV = False
        assert settings.LANGUAGE_URL_MAP == {'en-us': 'en-US'}, \
               ('DEV is False, but PROD_LANGUAGES are not used to define the '
                'allowed locales.')
Ejemplo n.º 12
0
from django_auth_ldap.config import _LDAPConfig, LDAPSearch

from funfactory.manage import path
from funfactory import settings_base as base
from settings import initial as pre

## Log settings
SYSLOG_TAG = "http_app_mozillians"
LOGGING = {
    'loggers': {
        'landing': {'level': logging.INFO},
        'phonebook': {'level': logging.INFO},
    },
}

LOCALE_PATHS = [path('locale')]


# Accepted locales
PROD_LANGUAGES = ('en-US', 'de', 'fr')

# List of RTL locales known to this project. Subset of LANGUAGES.
RTL_LANGUAGES = ()  # ('ar', 'fa', 'fa-IR', 'he')

# For absoluate urls
PROTOCOL = "https://"
PORT = 443

## Media and templates.

# List of callables that know how to import templates from various sources.
Ejemplo n.º 13
0
                            'vendor', 'src', 'funfactory')
    sys.path.append(tmp_path)

    from funfactory import manage

    # Let the path magic happen in setup_environ() !
    sys.path.remove(tmp_path)


manage.setup_environ(__file__, more_pythonic=True)

# We build binary packages on jenkins which installs itself
# in vendor-local/lib64/python
# Add it to sys.path just after vendor-local/lib/python which
# funfactory already added
_new_path = manage.path('vendor-local/lib64/python')
site.addsitedir(
    os.path.abspath(
        _new_path
    )
)
# now re-arrange so the order is right
_other_path = manage.path('vendor-local/lib/python')
sys.path.insert(sys.path.index(_other_path) + 1, _new_path)
_other_path = manage.path('vendor-local')
sys.path.insert(sys.path.index(_other_path) + 1, _new_path)


if __name__ == "__main__":
    manage.main()
Ejemplo n.º 14
0
Archivo: base.py Proyecto: g-k/elmo
            ],
            'debug':
            False
        }
    },
]

# This is the common prefix displayed in front of ALL static files
STATIC_URL = '/static/'

# the location where all collected files end up.
# the reason for repeated the word 'static' inside 'collected/'
# is so we, in nginx/apache, can set up the root to be
# <base path>/collected
# then a URL like http://domain/static/js/jquery.js just works
STATIC_ROOT = COMPRESS_ROOT = path('collected', 'static')

## Middlewares, apps, URL configs.

# not using funfactory.settings_base.MIDDLEWARE_CLASSES here because there's
# so few things we need and so many things we'd need to add
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'session_csrf.CsrfMiddleware',
    'commonware.middleware.FrameOptionsHeader',
    'commonware.middleware.ScrubRequestOnException',
)
Ejemplo n.º 15
0
 def _migrations_path():
     """Return the absolute path to the migration script folder."""
     return path('migrations')
Ejemplo n.º 16
0
# Django settings for the mozillians project.
import ldap
import logging

from django_auth_ldap.config import _LDAPConfig, LDAPSearch

from funfactory.manage import path
from funfactory import settings_base as base
from settings import initial as pre

## Log settings
SYSLOG_TAG = "http_app_mozillians"
LOGGING = {"loggers": {"landing": {"level": logging.INFO}, "phonebook": {"level": logging.INFO}}}

## L10n
LOCALE_PATHS = [path("locale")]

# Accepted locales
PROD_LANGUAGES = (
    "ca",
    "cs",
    "de",
    "en-US",
    "es",
    "hu",
    "fr",
    "ko",
    "nl",
    "pl",
    "pt-BR",
    "ru",
Ejemplo n.º 17
0
# Gettext text domain
TEXT_DOMAIN = 'messages'
STANDALONE_DOMAINS = [TEXT_DOMAIN, 'javascript']
TOWER_KEYWORDS = {'_lazy': None}
TOWER_ADD_HEADERS = True

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'zh-TW'

## Accepted locales

# Tells the product_details module where to find our local JSON files.
# This ultimately controls how LANGUAGES are constructed.
PROD_DETAILS_DIR = path('lib/product_details_json')

# On dev instances, the list of accepted locales defaults to the contents of
# the `locale` directory within a project module or, for older Playdoh apps,
# the root locale directory.  A localizer can add their locale in the l10n
# repository (copy of which is checked out into `locale`) in order to start
# testing the localization on the dev server.
import glob
import itertools

try:
    DEV_LANGUAGES = [
        os.path.basename(loc).replace('_', '-')
        for loc in itertools.chain(glob.iglob(ROOT + '/locale/*'), # old style
                                   glob.iglob(ROOT + '/*/locale/*'))
        if (os.path.isdir(loc) and os.path.basename(loc) != 'templates')
Ejemplo n.º 18
0
# Maximum size, in bytes, of published pages. Note that if you change this
# from its default, you may need to modify your database, since this
# setting's value is used in schema generation.
MAX_PUBLISHED_PAGE_SIZE = 100000

# Where to retrieve in-development learning projects from. Only
# consulted if settings.DEV is True.
LEARNING_PROJECTS_DROPBOXES = {
    'dropbox': {
        'static': 'sd',
        'url': 'http://wpm-dropbox.toolness.org/'
    },
    'nesta': {
        'static': 'sn',
        'url': 'http://labs.toolness.com/temp/nesta/'
    }
}

# Where to serve static resources for learning projects from, relative to
# server root. Note that this also needs to be present in
# SUPPORTED_NONLOCALES.
LEARNING_PROJECTS_STATIC_URL = '/s/'

# Root directory to serve learning project static resources from when
# in debug mode.
LEARNING_PROJECTS_STATIC_ROOT = path('webpagemaker/learning_projects/static')

# Use our symlink for the admin media.
ADMIN_MEDIA_PREFIX = '/media/admin/'
Ejemplo n.º 19
0
try:
    # For local development in a virtualenv:
    from funfactory import manage
except ImportError:
    # Production:
    # Add a temporary path so that we can import the funfactory
    tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "vendor", "src", "funfactory")
    sys.path.append(tmp_path)

    from funfactory import manage

    # Let the path magic happen in setup_environ() !
    sys.path.remove(tmp_path)


manage.setup_environ(__file__, more_pythonic=True)

# We build binary packages on jenkins which installs itself
# in vendor-local/lib64/python
# Add it to sys.path just after vendor-local/lib/python which
# funfactory already added
_new_path = manage.path("vendor-local/lib64/python")
site.addsitedir(os.path.abspath(_new_path))
# now re-arrange so the order is right
_other_path = manage.path("vendor-local/lib/python")
sys.path.insert(sys.path.index(_other_path) + 1, _new_path)


if __name__ == "__main__":
    manage.main()
Ejemplo n.º 20
0
 def setup_class(cls):
     os.environ['OPENLDAP_DB_PATH'] = '/home/vagrant/openldap-db'
     call(path('directory/devslapd/bin/x-rebuild'))
Ejemplo n.º 21
0
 def setup_class(cls):
     os.environ['OPENLDAP_DB_PATH'] = '/home/vagrant/openldap-db'
     call(path('directory/devslapd/bin/x-rebuild'))
Ejemplo n.º 22
0
# -*- coding: utf-8 -*-

# Django settings for the mozillians project.
import logging
import os

from funfactory.manage import path
from funfactory import settings_base as base
from settings import initial as pre

## Log settings
SYSLOG_TAG = "http_app_mozillians"
LOGGING = {"loggers": {"landing": {"level": logging.INFO}, "phonebook": {"level": logging.INFO}}}

## L10n
LOCALE_PATHS = [path("locale")]

# Accepted locales
PROD_LANGUAGES = (
    "ca",
    "cs",
    "de",
    "en-US",
    "es",
    "hu",
    "fr",
    "ko",
    "nl",
    "pl",
    "pt-BR",
    "ru",
Ejemplo n.º 23
0
## Log settings
SYSLOG_TAG = "http_app_mozillians"
LOGGING = {
    'loggers': {
        'landing': {
            'level': logging.INFO
        },
        'phonebook': {
            'level': logging.INFO
        },
    },
}

## L10n
LOCALE_PATHS = [path('locale')]

# Accepted locales
PROD_LANGUAGES = ('ca', 'cs', 'de', 'en-US', 'es', 'hu', 'fr', 'ko', 'nl',
                  'pl', 'pt-BR', 'ru', 'sk', 'sl', 'sq', 'zh-TW', 'lt', 'ja')

# List of RTL locales known to this project. Subset of LANGUAGES.
RTL_LANGUAGES = ()  # ('ar', 'fa', 'fa-IR', 'he')

# For absoluate urls
PROTOCOL = "https://"
PORT = 443

## Media and templates.
TEMPLATE_DIRS = (path('apps/users/templates'), )
Ejemplo n.º 24
0
from funfactory.settings_base import *
from funfactory.manage import path


LESS_PREPROCESS = True
LESS_BIN = '/usr/local/bin/lessc'

COFFEE_PREPROCESS = True
COFFEE_BIN = 'coffee'

MEDIA_ROOT = path('m')

STATIC_ROOT = path('s')
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    path('static'),
)

# For integration with staticfiles, this should be the same as STATIC_URL
# followed by 'admin/'.
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

# Bundles is a dictionary of two dictionaries, css and js, which list css files
# and js files that can be bundled together by the minify app.
MINIFY_BUNDLES = {

    'css': {

        'common': (
            'css/location-picker.css',
Ejemplo n.º 25
0
    # For local development in a virtualenv:
    from funfactory import manage
except ImportError:
    # Production:
    # Add a temporary path so that we can import the funfactory
    tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            'vendor', 'src', 'funfactory')
    sys.path.append(tmp_path)

    from funfactory import manage

    # Let the path magic happen in setup_environ() !
    sys.path.remove(tmp_path)

manage.setup_environ(__file__, more_pythonic=True)

# We build binary packages on jenkins which installs itself
# in vendor-local/lib64/python
# Add it to sys.path just after vendor-local/lib/python which
# funfactory already added
_new_path = manage.path('vendor-local/lib64/python')
site.addsitedir(os.path.abspath(_new_path))
# now re-arrange so the order is right
_other_path = manage.path('vendor-local/lib/python')
sys.path.insert(sys.path.index(_other_path) + 1, _new_path)
_other_path = manage.path('vendor-local')
sys.path.insert(sys.path.index(_other_path) + 1, _new_path)

if __name__ == "__main__":
    manage.main()
Ejemplo n.º 26
0
def load_data():
    fixture_path = path('apps/stores/fixtures/sample.json')
    call_command('loaddata', fixture_path, interactive=False, verbosity=0)