def create_motor_selections(self, boat, motors):
     for motor in motors:
         selection_model = MotorSelection.objects.create(motor=motor,
                                                         boat=boat)
         selections = self.motor_selection.get(motor.title, {})
         for selection_name, attrs in selections.items():
             lib_path = environ.Path(__file__) - 1
             files_path = join(str(lib_path), "images", "groups", "boats",
                               "motors", attrs["image"])
             with open(files_path, "rb") as an_image:
                 content = ContentFile(an_image.read(),
                                       basename(files_path))
                 selection_model.options.create(title=selection_name,
                                                image=content)
 def create_motors(self):
     motors = []
     lib_path = environ.Path(__file__) - 1
     files_path = join(str(lib_path), "images", "motors")
     for key, attrs in self.motors.items():
         image_page = join(
             files_path,
             attrs["image"],
         )
         with open(image_page, "rb") as an_image:
             motor, _ = Motor.objects.get_or_create(
                 title=key,
                 image=ContentFile(an_image.read(), basename(image_page)))
             motors.append(motor)
     return motors
 def handle(self, *args, **options):
     lib_path = environ.Path(__file__) - 1
     files_path = join(str(lib_path), "images", "groups")
     motors = self.create_motors()
     for group_name, attrs in self.objects.items():
         image_page = join(
             files_path,
             attrs["image"],
         )
         boats = attrs.get("boats", {})
         with open(image_page, "rb") as an_image:
             self.create_group(
                 group_name,
                 ContentFile(an_image.read(), basename(image_page)), boats,
                 motors)
    def create_about_data(self, boat):
        description = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ne in odium veniam, si amicum
        destitero tueri. Commoda autem et incommoda in eo genere sunt Lorem ipsum dolor sit amet, consectetur
        adipiscing elit. Ne in odium veniam, si amicum destitero tueri. Commoda autem et incommoda in eo gener

        Sunt Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ne in odium veniam, si amicum destitero
        tueri. Commoda autem et incommoda in eo genere sunte sunt

        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ne in odium veniam, si amicum"""

        lib_path = environ.Path(__file__) - 1
        brochure_path = join(str(lib_path), "files", "a_brochure.pdf")
        with open(brochure_path, "rb") as a_file:
            about_the_boat = AboutTheBoat.objects.create(
                title='Lorem ipsum dolor sit amet, consectetur',
                description=description,
                brochure=ContentFile(a_file.read(), basename(brochure_path)),
                boat=boat,
            )

        self.create_about_galleries(about_the_boat)
예제 #5
0
    def handle(self, *args, **options):
        lib_path = environ.Path(__file__) - 1
        files_path = join(str(lib_path), "images", "boats")

        for boat_name, attrs in self.objects.items():
            boat = Boat.objects.get(title=attrs["boat_name"])
            admin_user = get_user_model().objects.get(
                username=attrs["user_name"])
            design_path = join(
                files_path,
                attrs["design"],
            )
            with open(design_path, "rb") as design:
                user_boat = UserBoat.objects.create(name=boat_name,
                                                    user=admin_user,
                                                    boat=boat,
                                                    design=ContentFile(
                                                        design.read(),
                                                        basename(design_path)),
                                                    notes=attrs["notes"])
                step = attrs["boat_step"]
                self.create_steps(user_boat, step)
    def create_features(self, boat_model):
        for name, attrs in self.features.items():
            lib_path = environ.Path(__file__) - 1
            file_path = join(str(lib_path), "images", "groups", "boats",
                             "features", attrs["image"])
            empty_path = join(str(lib_path), "images", "groups", "boats",
                              "features", "empty.png")

            with open(empty_path, "rb") as empty_image:
                empty_content = ContentFile(empty_image.read(),
                                            basename(empty_path))
                with open(file_path, "rb") as an_image:
                    content = ContentFile(an_image.read(), basename(file_path))

                    feature = boat_model.features.create(title=name,
                                                         kind=attrs["kind"],
                                                         available=True)
                    feature.options.create(image=content,
                                           title="Yes",
                                           display_value=feature.title)
                    feature.options.create(image=empty_content,
                                           title="No",
                                           default=True)
예제 #7
0
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
from environ import environ

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# (dorkal/conf/settings/base.py - 3 = backend/)
ROOT_DIR = environ.Path(__file__) - 3
APPS_DIR = ROOT_DIR.path('backend')

# Load operating system environment variables and then prepare to use them
env = environ.Env()

# .env file, should load only in development environment
READ_DOT_ENV_FILE = env.bool('DJANGO_READ_DOT_ENV_FILE', default=True)

if READ_DOT_ENV_FILE:
    # Operating System Environment variables have precedence over variables defined in the .env file,
    # that is to say variables from the .env files will only be used if not defined
    # as environment variables.
    env_file = str(ROOT_DIR('.env'))
    print('Loading: {} '.format(env_file))
    env.read_env(env_file)
예제 #8
0
from __future__ import unicode_literals
from setuptools import setup, find_packages

from environ import environ

here = environ.Path(__file__, is_file=True)
README = open(here('README.rst')).read()

version = ".".join(map(str, environ.__version__))
author = environ.__author__
description = environ.__doc__
install_requires = []  # 'django'

setup(
    name='django-environ',
    version=version,
    description=description,
    long_description=README,
    classifiers=[
        # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Information Technology',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 3',
        'Topic :: Software Development :: Libraries :: Python Modules',
        'Topic :: Utilities',
        'License :: OSI Approved :: MIT License',
        'Framework :: Django'
    ],
    keywords='django environment variables 12factor',