diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..8146c75 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[run] +include = weird-little-empire/* +omit = *migrations*, *tests* +plugins = + django_coverage_plugin diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0bff0df --- /dev/null +++ b/.editorconfig @@ -0,0 +1,29 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{py,rst,ini}] +indent_style = space +indent_size = 4 + +[*.py] +line_length = 119 +known_first_party = my-shop +multi_line_output = 3 +default_section = THIRDPARTY + +[*.{html,js,rst,scss}] +indent_style = tab +indent_size = 4 + +[*.md] +trim_trailing_whitespace = false + +[*.txt] +insert_final_newline = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore index f8b73e7..73ea9b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,140 +1,34 @@ -# ---> Python -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ +*.pyc +.project +.pydevproject +.settings .tox/ -.nox/ -.coverage -.coverage.* .cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings +*.coverage +*~ +private_settings.py +build +docs/_build +docs/web_build +dist +*egg-info* +htmlcov +test-reports +bin/ +include/ +lib/ +distribute* +share/ +*.sqlite +database.db +*.swp +.DS_store +*coverage.xml +.idea .ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - +OLD-out-of-date +.tox +node_modules/ +workdir/ +django-shop-workdir_* +.pytest_cache/ diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..feecc1b --- /dev/null +++ b/.pylintrc @@ -0,0 +1,14 @@ +[MASTER] +load-plugins=pylint_common, pylint_django + +[FORMAT] +max-line-length=120 + +[MESSAGES CONTROL] +disable=missing-docstring,invalid-name + +[DESIGN] +max-parents=13 + +[TYPECHECK] +generated-members=REQUEST,acl_users,aq_parent,"[a-zA-Z]+_set{1,2}",save,delete diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5ca54d0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +sudo: true +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq build-essential gettext python-dev zlib1g-dev libpq-dev xvfb + - sudo apt-get install -qq libtiff4-dev libjpeg8-dev libfreetype6-dev liblcms1-dev libwebp-dev + - sudo apt-get install -qq graphviz-dev python-setuptools python3-dev python-virtualenv python-pip + - sudo apt-get install -qq firefox automake libtool libreadline6 libreadline6-dev libreadline-dev + - sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm +language: python +python: + - "3.6" diff --git a/Pipfile b/Pipfile index 5aeae39..b9a6bf7 100644 --- a/Pipfile +++ b/Pipfile @@ -1,16 +1,50 @@ [[source]] -url = "https://pypi.org/simple" +url = "https://pypi.python.org/simple" verify_ssl = true name = "pypi" [packages] -shuup = "*" -django = "*" -django-tailwind = "*" +Django = ">=3" +django-compressor = "*" +django-allauth = "*" +django-angular = ">=2.3" django-filer = "*" -django-bootstrap3 = "*" +django-ipware = "*" +django-sass-processor = "*" +django-select2 = "*" +django-filter = "*" +djangorestframework = "*" +django-rest-auth = "*" +django-polymorphic = ">=2.1" +django-admin-sortable2 = "*" +django-fsm = "*" +django-fsm-admin = "*" +django-phonenumber-field = "*" +django-post_office = "*" +phonenumbers = "*" +django-cms = ">=3.7.2" +djangocms-bootstrap = "*" +djangocms-cascade = ">=1.3.1" +djangocms-text-ckeditor = ">=3.9.1" +libsass = "*" +django-shop = ">=1.2.1" +django-elasticsearch-dsl = "*" +elasticsearch-dsl = ">=7" +djangoshop-stripe = ">=1.2" +stripe = "<2" + [dev-packages] +tox = "*" +pytest = "*" +pytest-django = "*" +beautifulsoup4 = "*" +lxml = "*" +factory-boy = "*" +pytest-factoryboy = "*" [requires] -python_version = "3.9" +python_version = "3.7" + +[pipenv] +allow_prereleases = true diff --git a/README.md b/README.md index c6b57dc..7161560 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ -# empire +# Weird Little Empire +This project is the merchant implementation for django-SHOP. It has been generated by this +[cookiecutter template](https://github.com/awesto/cookiecutter-django-shop). diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..5bb3d09 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,153 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/weird-little-empire.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/weird-little-empire.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/weird-little-empire" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/weird-little-empire" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/docs/__init__.py b/docs/__init__.py new file mode 100644 index 0000000..8772c82 --- /dev/null +++ b/docs/__init__.py @@ -0,0 +1 @@ +# Included so that Django's startproject comment runs against the docs directory diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..9098929 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,255 @@ +# Weird Little Empire documentation build configuration file, created by +# sphinx-quickstart. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import os +import sys + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# The suffix of source filenames. +source_suffix = ".rst" + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = "Weird Little Empire" +copyright = """2021, A Jones""" + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = "0.1" +# The full version, including alpha/beta/rc tags. +release = "0.1" + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "default" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = "weird-little-empiredoc" + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ( + "index", + "weird-little-empire.tex", + "Weird Little Empire Documentation", + """A Jones""", + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + "index", + "weird-little-empire", + "Weird Little Empire Documentation", + ["""A Jones"""], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + "index", + "weird-little-empire", + "Weird Little Empire Documentation", + """A Jones""", + "Weird Little Empire", + """Oddities from the black heart of the Old World""", + "Miscellaneous", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' diff --git a/docs/deploy.rst b/docs/deploy.rst new file mode 100644 index 0000000..1e642c7 --- /dev/null +++ b/docs/deploy.rst @@ -0,0 +1,4 @@ +Deploy +======== + +This is where you describe how the project is deployed in production. diff --git a/docs/docker_ec2.rst b/docs/docker_ec2.rst new file mode 100644 index 0000000..606d295 --- /dev/null +++ b/docs/docker_ec2.rst @@ -0,0 +1,186 @@ +Developing with Docker +====================== + +You can develop your application in a `Docker`_ container for simpler deployment onto bare Linux machines later. This instruction assumes an `Amazon Web Services`_ EC2 instance, but it should work on any machine with Docker > 1.3 and `Docker compose`_ installed. + +.. _Docker: https://www.docker.com/ +.. _Amazon Web Services: http://aws.amazon.com/ +.. _Docker compose: https://docs.docker.com/compose/ + +Setting up +^^^^^^^^^^ + +Docker encourages running one container for each process. This might mean one container for your web server, one for Django application and a third for your database. Once you're happy composing containers in this way you can easily add more, such as a `Redis`_ cache. + +.. _Redis: http://redis.io/ + +The Docker compose tool (previously known as `fig`_) makes linking these containers easy. An example set up for your Cookiecutter Django project might look like this: + +.. _fig: http://www.fig.sh/ + +:: + + webapp/ # Your cookiecutter project would be in here + Dockerfile + ... + database/ + Dockerfile + ... + webserver/ + Dockerfile + ... + production.yml + +Each component of your application would get its own `Dockerfile`_. The rest of this example assumes you are using the `base postgres image`_ for your database. Your database settings in `config/base.py` might then look something like: + +.. _Dockerfile: https://docs.docker.com/reference/builder/ +.. _base postgres image: https://registry.hub.docker.com/_/postgres/ + +.. code-block:: python + + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'postgres', + 'USER': 'postgres', + 'HOST': 'database', + 'PORT': 5432, + } + } + +The `Docker compose documentation`_ explains in detail what you can accomplish in the `production.yml` file, but an example configuration might look like this: + +.. _Docker compose documentation: https://docs.docker.com/compose/#compose-documentation + +.. code-block:: yaml + + database: + build: database + webapp: + build: webapp: + command: /usr/bin/python3.6 manage.py runserver 0.0.0.0:8000 # dev setting + # command: gunicorn -b 0.0.0.0:8000 wsgi:application # production setting + volumes: + - webapp/your_project_name:/path/to/container/workdir/ + links: + - database + webserver: + build: webserver + ports: + - "80:80" + - "443:443" + links: + - webapp + +We'll ignore the webserver for now (you'll want to comment that part out while we do). A working Dockerfile to run your cookiecutter application might look like this: + +:: + + FROM ubuntu:14.04 + ENV REFRESHED_AT 2015-01-13 + + # update packages and prepare to build software + RUN ["apt-get", "update"] + RUN ["apt-get", "-y", "install", "build-essential", "vim", "git", "curl"] + RUN ["locale-gen", "en_GB.UTF-8"] + + # install latest python + RUN ["apt-get", "-y", "build-dep", "python3-dev", "python3-imaging"] + RUN ["apt-get", "-y", "install", "python3-dev", "python3-imaging", "python3-pip"] + + # prepare postgreSQL support + RUN ["apt-get", "-y", "build-dep", "python3-psycopg2"] + + # move into our working directory + # ADD must be after chown see http://stackoverflow.com/a/26145444/1281947 + RUN ["groupadd", "python"] + RUN ["useradd", "python", "-s", "/bin/bash", "-m", "-g", "python", "-G", "python"] + ENV HOME /home/python + WORKDIR /home/python + RUN ["chown", "-R", "python:python", "/home/python"] + ADD ./ /home/python + + # manage requirements + ENV REQUIREMENTS_REFRESHED_AT 2015-02-25 + RUN ["pip3", "install", "-r", "requirements.txt"] + + # uncomment the line below to use container as a non-root user + USER python:python + +Running `sudo docker-compose -f production.yml build` will follow the instructions in your `production.yml` file and build the database container, then your webapp, before mounting your cookiecutter project files as a volume in the webapp container and linking to the database. Our example yaml file runs in development mode but changing it to production mode is as simple as commenting out the line using `runserver` and uncommenting the line using `gunicorn`. + +Both are set to run on port `0.0.0.0:8000`, which is where the Docker daemon will discover it. You can now run `sudo docker-compose -f production.yml up` and browse to `localhost:8000` to see your application running. + +Deployment +^^^^^^^^^^ + +You'll need a webserver container for deployment. An example setup for `Nginx`_ might look like this: + +.. _Nginx: http://wiki.nginx.org/Main + +:: + + FROM ubuntu:14.04 + ENV REFRESHED_AT 2015-02-11 + + # get the nginx package and set it up + RUN ["apt-get", "update"] + RUN ["apt-get", "-y", "install", "nginx"] + + # forward request and error logs to docker log collector + RUN ln -sf /dev/stdout /var/log/nginx/access.log + RUN ln -sf /dev/stderr /var/log/nginx/error.log + VOLUME ["/var/cache/nginx"] + EXPOSE 80 443 + + # load nginx conf + ADD ./site.conf /etc/nginx/sites-available/your_cookiecutter_project + RUN ["ln", "-s", "/etc/nginx/sites-available/your_cookiecutter_project", "/etc/nginx/sites-enabled/your_cookiecutter_project"] + RUN ["rm", "-rf", "/etc/nginx/sites-available/default"] + + #start the server + CMD ["nginx", "-g", "daemon off;"] + +That Dockerfile assumes you have an Nginx conf file named `site.conf` in the same directory as the webserver Dockerfile. A very basic example, which forwards traffic onto the development server or gunicorn for processing, would look like this: + +:: + + # see http://serverfault.com/questions/577370/how-can-i-use-environment-variables-in-nginx-conf#comment730384_577370 + upstream localhost { + server webapp_1:8000; + } + server { + location / { + proxy_pass http://localhost; + } + } + +Running `sudo docker-compose -f production.yml build webserver` will build your server container. Running `sudo docker-compose -f production.yml up` will now expose your application directly on `localhost` (no need to specify the port number). + +Building and running your app on EC2 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +All you now need to do to run your app in production is: + +* Create an empty EC2 Linux instance (any Linux machine should do). + +* Install your preferred source control solution, Docker and Docker compose on the news instance. + +* Pull in your code from source control. The root directory should be the one with your `production.yml` file in it. + +* Run `sudo docker-compose -f production.yml build` and `sudo docker-compose -f production.yml up`. + +* Assign an `Elastic IP address`_ to your new machine. + +.. _Elastic IP address: https://aws.amazon.com/articles/1346 + +* Point your domain name to the elastic IP. + +**Be careful with Elastic IPs** because, on the AWS free tier, if you assign one and then stop the machine you will incur charges while the machine is down (presumably because you're preventing them allocating the IP to someone else). + +Security advisory +^^^^^^^^^^^^^^^^^ + +The setup described in this instruction will get you up-and-running but it hasn't been audited for security. If you are running your own setup like this it is always advisable to, at a minimum, examine your application with a tool like `OWASP ZAP`_ to see what security holes you might be leaving open. + +.. _OWASP ZAP: https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..fb36002 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,26 @@ +.. Weird Little Empire documentation master file, created by + sphinx-quickstart. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Weird Little Empire's documentation! +==================================================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + install + deploy + docker_ec2 + tests + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/install.rst b/docs/install.rst new file mode 100644 index 0000000..1bc0333 --- /dev/null +++ b/docs/install.rst @@ -0,0 +1,4 @@ +Install +========= + +This is where you write how to get a new laptop to run this project. diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..742ca15 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,190 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\weird-little-empire.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\weird-little-empire.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end diff --git a/docs/pycharm/configuration.rst b/docs/pycharm/configuration.rst new file mode 100644 index 0000000..dd25b21 --- /dev/null +++ b/docs/pycharm/configuration.rst @@ -0,0 +1,64 @@ +Docker Remote Debugging +======================= + +To connect to python remote interpreter inside docker, you have to make sure first, that Pycharm is aware of your docker. + +Go to *Settings > Build, Execution, Deployment > Docker*. If you are on linux, you can use docker directly using its socket `unix:///var/run/docker.sock`, if you are on Windows or Mac, make sure that you have docker-machine installed, then you can simply *Import credentials from Docker Machine*. + +.. image:: images/1.png + +Configure Remote Python Interpreter +----------------------------------- + +This repository comes with already prepared "Run/Debug Configurations" for docker. + +.. image:: images/2.png + +But as you can see, at the beggining there is something wrong with them. They have red X on django icon, and they cannot be used, without configuring remote python interpteter. To do that, you have to go to *Settings > Build, Execution, Deployment* first. + + +Next, you have to add new remote python interpreter, based on already tested deployment settings. Go to *Settings > Project > Project Interpreter*. Click on the cog icon, and click *Add Remote*. + +.. image:: images/3.png + +Switch to *Docker Compose* and select `local.yml` file from directory of your project, next set *Service name* to `django` + +.. image:: images/4.png + +Having that, click *OK*. Close *Settings* panel, and wait few seconds... + +.. image:: images/7.png + +After few seconds, all *Run/Debug Configurations* should be ready to use. + +.. image:: images/8.png + +**Things you can do with provided configuration**: + +* run and debug python code +.. image:: images/f1.png +* run and debug tests +.. image:: images/f2.png +.. image:: images/f3.png +* run and debug migrations or different django management commands +.. image:: images/f4.png +* and many others.. + +Known issues +------------ + +* Pycharm hangs on "Connecting to Debugger" + +.. image:: images/issue1.png + +This might be fault of your firewall. Take a look on this ticket - https://youtrack.jetbrains.com/issue/PY-18913 + +* Modified files in `.idea` directory + +Most of the files from `.idea/` were added to `.gitignore` with a few exceptions, which were made, to provide "ready to go" configuration. After adding remote interpreter some of these files are altered by PyCharm: + +.. image:: images/issue2.png + +In theory you can remove them from repository, but then, other people will lose a ability to initialize a project from provided configurations as you did. To get rid of this annoying state, you can run command:: + + $ git update-index --assume-unchanged weird-little-empire.iml diff --git a/docs/pycharm/images/1.png b/docs/pycharm/images/1.png new file mode 100644 index 0000000..06908a1 Binary files /dev/null and b/docs/pycharm/images/1.png differ diff --git a/docs/pycharm/images/2.png b/docs/pycharm/images/2.png new file mode 100644 index 0000000..1fb8cf1 Binary files /dev/null and b/docs/pycharm/images/2.png differ diff --git a/docs/pycharm/images/3.png b/docs/pycharm/images/3.png new file mode 100644 index 0000000..32c9335 Binary files /dev/null and b/docs/pycharm/images/3.png differ diff --git a/docs/pycharm/images/4.png b/docs/pycharm/images/4.png new file mode 100644 index 0000000..cf07f9d Binary files /dev/null and b/docs/pycharm/images/4.png differ diff --git a/docs/pycharm/images/7.png b/docs/pycharm/images/7.png new file mode 100644 index 0000000..4f8807e Binary files /dev/null and b/docs/pycharm/images/7.png differ diff --git a/docs/pycharm/images/8.png b/docs/pycharm/images/8.png new file mode 100644 index 0000000..05946f2 Binary files /dev/null and b/docs/pycharm/images/8.png differ diff --git a/docs/pycharm/images/f1.png b/docs/pycharm/images/f1.png new file mode 100644 index 0000000..2d8c4b6 Binary files /dev/null and b/docs/pycharm/images/f1.png differ diff --git a/docs/pycharm/images/f2.png b/docs/pycharm/images/f2.png new file mode 100644 index 0000000..b123a47 Binary files /dev/null and b/docs/pycharm/images/f2.png differ diff --git a/docs/pycharm/images/f3.png b/docs/pycharm/images/f3.png new file mode 100644 index 0000000..713ab54 Binary files /dev/null and b/docs/pycharm/images/f3.png differ diff --git a/docs/pycharm/images/f4.png b/docs/pycharm/images/f4.png new file mode 100644 index 0000000..11668ec Binary files /dev/null and b/docs/pycharm/images/f4.png differ diff --git a/docs/pycharm/images/issue1.png b/docs/pycharm/images/issue1.png new file mode 100644 index 0000000..1bb68ee Binary files /dev/null and b/docs/pycharm/images/issue1.png differ diff --git a/docs/pycharm/images/issue2.png b/docs/pycharm/images/issue2.png new file mode 100644 index 0000000..174f6fd Binary files /dev/null and b/docs/pycharm/images/issue2.png differ diff --git a/dumpdata.sh b/dumpdata.sh new file mode 100755 index 0000000..a65a4ad --- /dev/null +++ b/dumpdata.sh @@ -0,0 +1,3 @@ +#!/bin/sh +mkdir -p workdir/fixtures +./manage.py dumpdata --indent=2 --natural-foreign email_auth cmsplugin_cascade.cascadeclipboard cmsplugin_cascade.pluginextrafields cmsplugin_cascade.sharedglossary filer post_office.emailtemplate shop --exclude filer.clipboard --exclude filer.clipboarditem > workdir/fixtures/skeleton.json diff --git a/locale/README.rst b/locale/README.rst new file mode 100644 index 0000000..c2f1dcd --- /dev/null +++ b/locale/README.rst @@ -0,0 +1,6 @@ +Translations +============ + +Translations will be placed in this folder when running:: + + python manage.py makemessages diff --git a/manage.py b/manage.py index 84923e4..042e58c 100755 --- a/manage.py +++ b/manage.py @@ -1,21 +1,10 @@ #!/usr/bin/env python -"""Django's command-line utility for administrative tasks.""" import os import sys - -def main(): - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings') - try: - from django.core.management import execute_from_command_line - except ImportError as exc: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) from exc - execute_from_command_line(sys.argv) - - if __name__ == '__main__': - main() + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'weirdlittleempire.settings') + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/package.json b/package.json new file mode 100644 index 0000000..d094a86 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "weird-little-empire", + "version": "1.0.0", + "description": "Oddities from the black heart of the Old World", + "private": true, + "dependencies": { + "angular": "^1.7.8", + "angular-animate": "^1.7.8", + "angular-bootstrap-plus": "^0.8.1", + "angular-i18n": "^1.7.8", + "angular-inview": "^3.0.0", + "angular-sanitize": "^1.7.8", + "angular-ui-bootstrap": "~2.5.6", + "autoprefixer": "^8.0.0", + "bootstrap": "^4.3.1", + "font-awesome": "^4.7.0", + "leaflet": "^1.1.0", + "leaflet-easybutton": "^2.2.0", + "postcss": "^6.0.23", + "postcss-cli": "^5.0.0", + "select2": "~4.0.3", + "ui-bootstrap4": "^3.0.5" + } +} diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..595bee1 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +DJANGO_SETTINGS_MODULE=config.settings.test +norecursedirs = node_modules diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..1ec89c7 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,7 @@ +[flake8] +max-line-length = 120 +exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules + +[pycodestyle] +max-line-length = 120 +exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules diff --git a/weirdlittleempire/__init__.py b/weirdlittleempire/__init__.py new file mode 100644 index 0000000..c13a4cf --- /dev/null +++ b/weirdlittleempire/__init__.py @@ -0,0 +1,2 @@ +__version__ = '0.0.1' +default_app_config = 'weirdlittleempire.apps.WeirdLittleEmpire' diff --git a/weirdlittleempire/admin.py b/weirdlittleempire/admin.py new file mode 100644 index 0000000..f995b81 --- /dev/null +++ b/weirdlittleempire/admin.py @@ -0,0 +1,130 @@ +from django.contrib import admin +from django.template.context import Context +from django.template.loader import get_template +from django.utils.translation import ugettext_lazy as _ +from filer.models import ThumbnailOption +from cms.admin.placeholderadmin import PlaceholderAdminMixin, FrontendEditableAdminMixin +from shop.admin.defaults import customer +from shop.admin.defaults.order import OrderAdmin +from shop.models.defaults.order import Order +from shop.admin.order import PrintInvoiceAdminMixin +from shop.admin.delivery import DeliveryOrderAdminMixin +from adminsortable2.admin import SortableAdminMixin, PolymorphicSortableAdminMixin +from shop.admin.product import CMSPageAsCategoryMixin, UnitPriceMixin, ProductImageInline, InvalidateProductCacheMixin, SearchProductIndexMixin, CMSPageFilter +from polymorphic.admin import (PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, + PolymorphicChildModelFilter) +from weirdlittleempire.models import Product, Commodity, SmartPhoneVariant, SmartPhoneModel, OperatingSystem +from weirdlittleempire.models import Manufacturer, SmartCard + + +admin.site.site_header = "Weird Little Empire Administration" +admin.site.unregister(ThumbnailOption) + + +@admin.register(Order) +class OrderAdmin(PrintInvoiceAdminMixin, DeliveryOrderAdminMixin, OrderAdmin): + pass + + +admin.site.register(Manufacturer, admin.ModelAdmin) + +__all__ = ['customer'] + + +@admin.register(Commodity) +class CommodityAdmin(InvalidateProductCacheMixin, SearchProductIndexMixin, SortableAdminMixin, FrontendEditableAdminMixin, + PlaceholderAdminMixin, CMSPageAsCategoryMixin, PolymorphicChildModelAdmin): + """ + Since our Commodity model inherits from polymorphic Product, we have to redefine its admin class. + """ + base_model = Product + fields = [ + ('product_name', 'slug'), + ('product_code', 'unit_price'), + 'quantity', + 'active', + 'caption', + 'manufacturer', + ] + filter_horizontal = ['cms_pages'] + inlines = [ProductImageInline] + prepopulated_fields = {'slug': ['product_name']} + + +@admin.register(SmartCard) +class SmartCardAdmin(InvalidateProductCacheMixin, SearchProductIndexMixin, SortableAdminMixin, FrontendEditableAdminMixin, + CMSPageAsCategoryMixin, PlaceholderAdminMixin, PolymorphicChildModelAdmin): + base_model = Product + fieldsets = ( + (None, { + 'fields': [ + ('product_name', 'slug'), + ('product_code', 'unit_price'), + 'quantity', + 'active', + 'caption', + 'description', + ], + }), + (_("Properties"), { + 'fields': ['manufacturer', 'storage', 'card_type', 'speed'], + }), + ) + filter_horizontal = ['cms_pages'] + inlines = [ProductImageInline] + prepopulated_fields = {'slug': ['product_name']} + + +admin.site.register(OperatingSystem, admin.ModelAdmin) + + +class SmartPhoneInline(admin.TabularInline): + model = SmartPhoneVariant + extra = 0 + + +@admin.register(SmartPhoneModel) +class SmartPhoneAdmin(InvalidateProductCacheMixin, SearchProductIndexMixin, SortableAdminMixin, FrontendEditableAdminMixin, + CMSPageAsCategoryMixin, PlaceholderAdminMixin, PolymorphicChildModelAdmin): + base_model = Product + fieldsets = [ + (None, { + 'fields': [ + ('product_name', 'slug'), + 'active', + 'caption', + 'description', + ], + }), + (_("Properties"), { + 'fields': ['manufacturer', 'battery_type', 'battery_capacity', 'ram_storage', + 'wifi_connectivity', 'bluetooth', 'gps', 'operating_system', + ('width', 'height', 'weight',), 'screen_size'], + }), + ] + filter_horizontal = ['cms_pages'] + inlines = [ProductImageInline, SmartPhoneInline] + prepopulated_fields = {'slug': ['product_name']} + + def render_text_index(self, instance): + template = get_template( + 'search/indexes/weirdlittleempire/commodity_text.txt') + return template.render(Context({'object': instance})) + render_text_index.short_description = _("Text Index") + + +@admin.register(Product) +class ProductAdmin(PolymorphicSortableAdminMixin, PolymorphicParentModelAdmin): + base_model = Product + child_models = [SmartPhoneModel, SmartCard, Commodity] + list_display = ['product_name', 'get_price', 'product_type', 'active'] + list_display_links = ['product_name'] + search_fields = ['product_name'] + list_filter = [PolymorphicChildModelFilter, CMSPageFilter] + list_per_page = 250 + list_max_show_all = 1000 + + def get_price(self, obj): + return str(obj.get_real_instance().get_price(None)) + + get_price.short_description = _("Price starting at") diff --git a/weirdlittleempire/apps.py b/weirdlittleempire/apps.py new file mode 100644 index 0000000..7886d6a --- /dev/null +++ b/weirdlittleempire/apps.py @@ -0,0 +1,24 @@ +import os +import logging +from django.apps import AppConfig +from django.conf import settings +from django.utils.translation import ugettext_lazy as _ + + +class WeirdLittleEmpire(AppConfig): + name = 'weirdlittleempire' + verbose_name = _("My Shop") + logger = logging.getLogger('weirdlittleempire') + + def ready(self): + if not os.path.isdir(settings.STATIC_ROOT): + os.makedirs(settings.STATIC_ROOT) + if not os.path.isdir(settings.MEDIA_ROOT): + os.makedirs(settings.MEDIA_ROOT) + if hasattr(settings, 'COMPRESS_ROOT') and not os.path.isdir(settings.COMPRESS_ROOT): + os.makedirs(settings.COMPRESS_ROOT) + as_i18n = "" + self.logger.info("Running as polymorphic{}".format(as_i18n)) + + from weirdlittleempire import search_indexes + __all__ = ['search_indexes'] diff --git a/weirdlittleempire/cms_apps.py b/weirdlittleempire/cms_apps.py new file mode 100644 index 0000000..a2d577c --- /dev/null +++ b/weirdlittleempire/cms_apps.py @@ -0,0 +1,60 @@ +from shop.cms_apphooks import CatalogSearchApp +from django.conf.urls import url +from rest_framework.settings import api_settings + +from cms.apphook_pool import apphook_pool +from cms.cms_menus import SoftRootCutter +from menus.menu_pool import menu_pool + +from shop.cms_apphooks import CatalogListCMSApp, CatalogSearchApp, OrderApp, PasswordResetApp +from shop.rest.filters import CMSPagesFilterBackend + + +class CatalogListApp(CatalogListCMSApp): + def get_urls(self, page=None, language=None, **kwargs): + from shop.search.mixins import ProductSearchViewMixin + from shop.views.catalog import AddToCartView, ProductListView, ProductRetrieveView + from shop.views.catalog import AddFilterContextMixin + from weirdlittleempire.filters import ManufacturerFilterSet + from weirdlittleempire.serializers import AddSmartPhoneToCartSerializer + + ProductListView = type( + 'ProductSearchListView', (AddFilterContextMixin, ProductSearchViewMixin, ProductListView), {}) + filter_backends = [CMSPagesFilterBackend] + filter_backends.extend(api_settings.DEFAULT_FILTER_BACKENDS) + return [ + url(r'^(?P[\w-]+)/add-to-cart', AddToCartView.as_view()), + url(r'^(?P[\w-]+)/add-smartphone-to-cart', AddToCartView.as_view( + serializer_class=AddSmartPhoneToCartSerializer, + )), + url(r'^(?P[\w-]+)', ProductRetrieveView.as_view( + use_modal_dialog=False, + )), + url(r'^', ProductListView.as_view( + filter_backends=filter_backends, + filter_class=ManufacturerFilterSet, + )), + ] + + +apphook_pool.register(CatalogListApp) + + +apphook_pool.register(CatalogSearchApp) + +apphook_pool.register(OrderApp) + +apphook_pool.register(PasswordResetApp) + + +def _deregister_menu_pool_modifier(Modifier): + index = None + for k, modifier_class in enumerate(menu_pool.modifiers): + if issubclass(modifier_class, Modifier): + index = k + if index is not None: + # intentionally only modifying the list + menu_pool.modifiers.pop(index) + + +_deregister_menu_pool_modifier(SoftRootCutter) diff --git a/weirdlittleempire/cms_wizards.py b/weirdlittleempire/cms_wizards.py new file mode 100644 index 0000000..31d77e9 --- /dev/null +++ b/weirdlittleempire/cms_wizards.py @@ -0,0 +1,3 @@ +from django.utils.translation import ugettext_lazy as _ +from cms.wizards.wizard_base import Wizard +from cms.wizards.wizard_pool import wizard_pool diff --git a/weirdlittleempire/filters.py b/weirdlittleempire/filters.py new file mode 100644 index 0000000..98ef781 --- /dev/null +++ b/weirdlittleempire/filters.py @@ -0,0 +1,39 @@ +from django.forms.widgets import Select +from django.utils.translation import ugettext_lazy as _ +from django_filters import FilterSet + +from djng.forms import NgModelFormMixin +from djng.styling.bootstrap3.forms import Bootstrap3Form + +from shop.filters import ModelChoiceFilter + +from weirdlittleempire.models import Manufacturer, Product + + +class FilterForm(NgModelFormMixin, Bootstrap3Form): + scope_prefix = 'filters' + + +class ManufacturerFilterSet(FilterSet): + manufacturer = ModelChoiceFilter( + queryset=Manufacturer.objects.all(), + widget=Select(attrs={'ng-change': 'filterChanged()'}), + empty_label=_("Any Manufacturer"), + help_text=_("Restrict product on this manufacturer only"), + ) + + class Meta: + model = Product + form = FilterForm + fields = ['manufacturer'] + + @classmethod + def get_render_context(cls, request, queryset): + # create filter set with bound form, to enable the selected option + filter_set = cls(data=request.GET) + + # we only want to show manufacturers for products available in the current list view + filter_field = filter_set.filters['manufacturer'].field + filter_field.queryset = filter_field.queryset.filter( + id__in=queryset.values_list('manufacturer_id')) + return dict(filter_set=filter_set) diff --git a/weirdlittleempire/finders.py b/weirdlittleempire/finders.py new file mode 100644 index 0000000..90790a0 --- /dev/null +++ b/weirdlittleempire/finders.py @@ -0,0 +1,43 @@ +import os +from django.conf import settings +from django.contrib.staticfiles.finders import (FileSystemFinder as FileSystemFinderBase, + AppDirectoriesFinder as AppDirectoriesFinderBase) + + +class FileSystemFinder(FileSystemFinderBase): + """ + In debug mode, serve /static/any/asset.min.ext as /static/any/asset.ext + """ + locations = [] + serve_unminimized = getattr(settings, 'DEBUG', False) + + def find_location(self, root, path, prefix=None): + if self.serve_unminimized: + # search for the unminimized version, and if it exists, return it + base, ext = os.path.splitext(path) + base, minext = os.path.splitext(base) + if minext == '.min': + unminimized_path = super().find_location(root, base + ext, prefix) + if unminimized_path: + return unminimized_path + # otherwise proceed with the given one + path = super().find_location(root, path, prefix) + return path + + +class AppDirectoriesFinder(AppDirectoriesFinderBase): + serve_unminimized = getattr(settings, 'DEBUG', False) + + def find_in_app(self, app, path): + matched_path = super().find_in_app(app, path) + if matched_path and self.serve_unminimized: + base, ext = os.path.splitext(matched_path) + base, minext = os.path.splitext(base) + if minext == '.min': + storage = self.storages.get(app, None) + path = '{}{}'.format(base, ext) + if storage.exists(path): + path = storage.path(path) + if path: + return path + return matched_path diff --git a/weirdlittleempire/forms.py b/weirdlittleempire/forms.py new file mode 100644 index 0000000..d8cdb5c --- /dev/null +++ b/weirdlittleempire/forms.py @@ -0,0 +1,5 @@ +from shop.forms.checkout import CustomerForm as CustomerFormBase + + +class CustomerForm(CustomerFormBase): + field_order = ['salutation', 'first_name', 'last_name', 'email'] diff --git a/weirdlittleempire/management/__init__.py b/weirdlittleempire/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/weirdlittleempire/management/commands/__init__.py b/weirdlittleempire/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/weirdlittleempire/management/commands/assign_iconfonts.py b/weirdlittleempire/management/commands/assign_iconfonts.py new file mode 100644 index 0000000..9796fa9 --- /dev/null +++ b/weirdlittleempire/management/commands/assign_iconfonts.py @@ -0,0 +1,37 @@ +from django.core.management.base import BaseCommand +from cmsplugin_cascade.icon.utils import zipfile, unzip_archive + + +class Command(BaseCommand): + help = "Iterates over all files in Filer and creates an IconFont for all eligibles." + + def handle(self, verbosity, *args, **options): + self.verbosity = verbosity + self.assign_files_to_iconfonts() + + def assign_files_to_iconfonts(self): + from filer.models.filemodels import File + from cmsplugin_cascade.models import IconFont + + for file in File.objects.all(): + if file.label != 'Font Awesome': + continue + if self.verbosity >= 2: + self.stdout.write( + "Creating Icon Font from: {}".format(file.label)) + try: + zip_ref = zipfile.ZipFile(file.file, 'r') + except zipfile.BadZipFile as exc: + self.stderr.write( + "Unable to unpack {}: {}".format(file.label, exc)) + else: + if not IconFont.objects.filter(zip_file=file).exists(): + font_folder, config_data = unzip_archive( + file.label, zip_ref) + IconFont.objects.create( + identifier=config_data['name'], + config_data=config_data, + zip_file=file, + font_folder=font_folder, + ) + zip_ref.close() diff --git a/weirdlittleempire/management/commands/create_social_icons.py b/weirdlittleempire/management/commands/create_social_icons.py new file mode 100644 index 0000000..84fd634 --- /dev/null +++ b/weirdlittleempire/management/commands/create_social_icons.py @@ -0,0 +1,41 @@ +from cms.models.static_placeholder import StaticPlaceholder +from django.core.management.base import BaseCommand +from cmsplugin_cascade.models import CascadeClipboard +from shop.management.utils import deserialize_to_placeholder + + +class Command(BaseCommand): + help = "Iterates over all files in Filer and creates an IconFont for all eligibles." + + def handle(self, verbosity, *args, **options): + self.verbosity = verbosity + self.create_social_icons() + + def create_social_icons(self): + from cms.utils.i18n import get_public_languages + + default_language = get_public_languages()[0] + + try: + clipboard = CascadeClipboard.objects.get(identifier='social-icons') + except CascadeClipboard.DoesNotExist: + self.stderr.write( + "No Persisted Clipboard named 'social-icons' found.") + else: + static_placeholder = StaticPlaceholder.objects.create( + code='Social Icons') + deserialize_to_placeholder( + static_placeholder.public, clipboard.data, default_language) + deserialize_to_placeholder( + static_placeholder.draft, clipboard.data, default_language) + self.stdout.write("Added Social Icons to Static Placeholder") + + def publish_in_all_languages(self, page): + from cms.api import copy_plugins_to_language + from cms.utils.i18n import get_public_languages + + languages = get_public_languages() + for language in languages[1:]: + copy_plugins_to_language(page, languages[0], language) + for language in languages: + page.publish(language) diff --git a/weirdlittleempire/management/commands/download_workdir.py b/weirdlittleempire/management/commands/download_workdir.py new file mode 100644 index 0000000..f4e9984 --- /dev/null +++ b/weirdlittleempire/management/commands/download_workdir.py @@ -0,0 +1,64 @@ +import os +import requests +from io import BytesIO as StringIO +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError +try: + import czipfile as zipfile +except ImportError: + import zipfile +from .spinner import Spinner + + +class Command(BaseCommand): + version = 18 + help = "Download workdir to run a demo of django-SHOP." + download_url = 'https://downloads.django-shop.org/django-shop-workdir-{version}.zip' + + def add_arguments(self, parser): + parser.add_argument( + '--noinput', + '--no-input', + action='store_false', + dest='interactive', + default=True, + help="Do NOT prompt the user for input of any kind.", + ) + + def set_options(self, **options): + self.interactive = options['interactive'] + + def handle(self, verbosity, *args, **options): + self.set_options(**options) + fixture1 = '{workdir}/fixtures/products-media.json'.format( + workdir=settings.WORK_DIR) + fixture2 = '{workdir}/fixtures/products-meta.json'.format( + workdir=settings.WORK_DIR) + if os.path.isfile(fixture1) or os.path.isfile(fixture2): + if self.interactive: + mesg = """ +This will overwrite your workdir for your django-SHOP demo. +Are you sure you want to do this? + +Type 'yes' to continue, or 'no' to cancel: +""" + if input(mesg) != 'yes': + raise CommandError( + "Downloading workdir has been cancelled.") + else: + self.stdout.write(self.style.WARNING( + "Can not override downloaded data in input-less mode.")) + return + + extract_to = os.path.join(settings.WORK_DIR, os.pardir) + msg = "Downloading workdir and extracting to {}. Please wait" + self.stdout.write(msg.format(extract_to), ending=' ') + with Spinner(): + download_url = self.download_url.format(version=self.version) + response = requests.get(download_url, stream=True) + zip_ref = zipfile.ZipFile(StringIO(response.content)) + try: + zip_ref.extractall(extract_to) + finally: + zip_ref.close() + self.stdout.write('- done.') diff --git a/weirdlittleempire/management/commands/export_products.py b/weirdlittleempire/management/commands/export_products.py new file mode 100644 index 0000000..62d31d6 --- /dev/null +++ b/weirdlittleempire/management/commands/export_products.py @@ -0,0 +1,35 @@ +import json +from django.conf import settings +from django.contrib.contenttypes.models import ContentType +from django.core.management.base import BaseCommand +from django.utils.module_loading import import_string +from django.utils.translation import activate +from weirdlittleempire.models import Product + + +class Command(BaseCommand): + def add_arguments(self, parser): + parser.add_argument( + '-o', + '--output', + type=str, + dest='filename', + ) + + def handle(self, verbosity, filename, *args, **options): + activate(settings.LANGUAGE_CODE) + data = [] + for product in Product.objects.all(): + ProductModel = ContentType.objects.get( + app_label='weirdlittleempire', model=product.product_model) + class_name = 'weirdlittleempire.management.serializers.' + \ + ProductModel.model_class().__name__ + 'Serializer' + serializer_class = import_string(class_name) + serializer = serializer_class(product, context={'request': None}) + data.append(serializer.data) + dump = json.dumps(data, indent=2) + if filename: + with open(filename, 'w') as fh: + fh.write(dump) + else: + self.stdout.write(dump) diff --git a/weirdlittleempire/management/commands/import_products.py b/weirdlittleempire/management/commands/import_products.py new file mode 100644 index 0000000..917d4da --- /dev/null +++ b/weirdlittleempire/management/commands/import_products.py @@ -0,0 +1,84 @@ +import json +import os +from cms.utils.copy_plugins import copy_plugins_to +from cms.utils.i18n import get_public_languages +from django.conf import settings +from django.contrib.contenttypes.models import ContentType +from django.core.management.base import BaseCommand, CommandError +from django.utils.module_loading import import_string +from django.utils.translation import activate +from cmsplugin_cascade.models import CascadeClipboard +from shop.management.utils import deserialize_to_placeholder + + +class Command(BaseCommand): + def add_arguments(self, parser): + parser.add_argument( + 'filename', + nargs='?', + default='products-meta.json', + ) + + def handle(self, verbosity, filename, *args, **options): + activate(settings.LANGUAGE_CODE) + path = self.find_fixture(filename) + if verbosity >= 2: + self.stdout.write("Importing products from: {}".format(path)) + with open(path, 'r') as fh: + data = json.load(fh) + + for number, product in enumerate(data, 1): + product_model = product.pop('product_model') + if product.get('product_code') == "parklake-springfield": + continue + ProductModel = ContentType.objects.get( + app_label='weirdlittleempire', model=product_model) + class_name = 'weirdlittleempire.management.serializers.' + \ + ProductModel.model_class().__name__ + 'Serializer' + serializer_class = import_string(class_name) + serializer = serializer_class(data=product) + assert serializer.is_valid(), serializer.errors + instance = serializer.save() + self.assign_product_to_catalog(instance) + self.stdout.write("{}. {}".format(number, instance)) + if product_model == 'commodity': + languages = get_public_languages() + try: + clipboard = CascadeClipboard.objects.get( + identifier=instance.slug) + except CascadeClipboard.DoesNotExist: + pass + else: + deserialize_to_placeholder( + instance.placeholder, clipboard.data, languages[0]) + plugins = list(instance.placeholder.get_plugins( + language=languages[0]).order_by('path')) + for language in languages[1:]: + copy_plugins_to( + plugins, instance.placeholder, language) + + def find_fixture(self, filename): + if os.path.isabs(filename): + fixture_dirs = [os.path.dirname(filename)] + fixture_name = os.path.basename(filename) + else: + fixture_dirs = settings.FIXTURE_DIRS + if os.path.sep in os.path.normpath(filename): + fixture_dirs = [os.path.join(dir_, os.path.dirname(filename)) + for dir_ in fixture_dirs] + fixture_name = os.path.basename(filename) + else: + fixture_name = filename + for fixture_dir in fixture_dirs: + path = os.path.join(fixture_dir, fixture_name) + if os.path.exists(path): + return path + raise CommandError( + "No such file in any fixture dir: {}".format(filename)) + + def assign_product_to_catalog(self, product): + from cms.models.pagemodel import Page + from shop.models.related import ProductPageModel + + for page in Page.objects.published().filter(application_urls='CatalogListApp'): + ProductPageModel.objects.get_or_create(page=page, product=product) diff --git a/weirdlittleempire/management/commands/initialize_inventories.py b/weirdlittleempire/management/commands/initialize_inventories.py new file mode 100644 index 0000000..ee11c49 --- /dev/null +++ b/weirdlittleempire/management/commands/initialize_inventories.py @@ -0,0 +1,26 @@ +import random +from django.core.management.base import BaseCommand +from weirdlittleempire.models import Commodity, CommodityInventory, SmartCard, SmartCardInventory, SmartPhoneVariant, SmartPhoneInventory + + +class Command(BaseCommand): + help = "Create Inventories for all products using random values." + + def handle(self, verbosity, *args, **options): + self.verbosity = verbosity + for commodity in Commodity.objects.all(): + CommodityInventory.objects.create( + product=commodity, + quantity=random.randint(0, 15) + ) + for smart_card in SmartCard.objects.all(): + SmartCardInventory.objects.create( + product=smart_card, + quantity=random.randint(0, 55) + ) + for smart_phone in SmartPhoneVariant.objects.all(): + SmartPhoneInventory.objects.create( + product=smart_phone, + quantity=random.randint(0, 8) + ) + self.stdout.write("Created inventories with random quantities.") diff --git a/weirdlittleempire/management/commands/initialize_shop_demo.py b/weirdlittleempire/management/commands/initialize_shop_demo.py new file mode 100644 index 0000000..528d650 --- /dev/null +++ b/weirdlittleempire/management/commands/initialize_shop_demo.py @@ -0,0 +1,104 @@ +import os +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError +from django.core.management import call_command +from django.utils.translation import ugettext_lazy as _ +try: + import czipfile as zipfile +except ImportError: + import zipfile + + +class Command(BaseCommand): + help = _("Initialize the workdir to run the demo of weirdlittleempire.") + + def add_arguments(self, parser): + parser.add_argument( + '--noinput', '--no-input', + action='store_false', + dest='interactive', + default=True, + help="Do NOT prompt the user for input of any kind.", + ) + + def set_options(self, **options): + self.interactive = options['interactive'] + + def clear_compressor_cache(self): + from django.core.cache import caches + from django.core.cache.backends.base import InvalidCacheBackendError + from compressor.conf import settings + + cache_dir = os.path.join(settings.STATIC_ROOT, + settings.COMPRESS_OUTPUT_DIR) + if settings.COMPRESS_ENABLED is False or not os.path.isdir(cache_dir) or os.listdir(cache_dir) != []: + return + try: + caches['compressor'].clear() + except InvalidCacheBackendError: + pass + + def handle(self, verbosity, *args, **options): + self.set_options(**options) + self.clear_compressor_cache() + call_command('migrate') + initialize_file = os.path.join(settings.WORK_DIR, '.initialize') + if os.path.isfile(initialize_file): + self.stdout.write("Initializing project weirdlittleempire") + call_command('makemigrations', 'weirdlittleempire') + call_command('migrate') + os.remove(initialize_file) + call_command('loaddata', 'skeleton') + call_command('shop', 'check-pages', add_recommended=True) + call_command('assign_iconfonts') + call_command('create_social_icons') + call_command('download_workdir', interactive=self.interactive) + call_command('loaddata', 'products-media') + call_command('import_products') + self.create_polymorphic_subcategories() + try: + call_command('search_index', action='rebuild', force=True) + except: + pass + else: + self.stdout.write("Project weirdlittleempire already initialized") + call_command('migrate') + + def create_polymorphic_subcategories(self): + from cms.models.pagemodel import Page + from shop.management.commands.shop import Command as ShopCommand + from weirdlittleempire.models import Commodity, SmartCard, SmartPhoneModel + + apphook = ShopCommand.get_installed_apphook('CatalogListCMSApp') + catalog_pages = Page.objects.drafts().filter( + application_urls=apphook.__class__.__name__) + assert catalog_pages.count() == 1, "There should be only one catalog page" + self.create_subcategory( + apphook, catalog_pages.first(), "Earphones", Commodity) + self.create_subcategory( + apphook, catalog_pages.first(), "Smart Cards", SmartCard) + self.create_subcategory( + apphook, catalog_pages.first(), "Smart Phones", SmartPhoneModel) + + def create_subcategory(self, apphook, parent_page, title, product_type): + from cms.api import create_page + from cms.constants import TEMPLATE_INHERITANCE_MAGIC + from cms.utils.i18n import get_public_languages + from shop.management.commands.shop import Command as ShopCommand + from shop.models.product import ProductModel + from shop.models.related import ProductPageModel + + language = get_public_languages()[0] + page = create_page( + title, + TEMPLATE_INHERITANCE_MAGIC, + language, + apphook=apphook, + created_by="manage.py initialize_shop_demo", + in_navigation=True, + parent=parent_page, + ) + ShopCommand.publish_in_all_languages(page) + page = page.get_public_object() + for product in ProductModel.objects.instance_of(product_type): + ProductPageModel.objects.create(page=page, product=product) diff --git a/weirdlittleempire/management/commands/spinner.py b/weirdlittleempire/management/commands/spinner.py new file mode 100644 index 0000000..d23b723 --- /dev/null +++ b/weirdlittleempire/management/commands/spinner.py @@ -0,0 +1,37 @@ +import sys +import time +import threading + + +class Spinner: + busy = False + delay = 0.1 + + @staticmethod + def spinning_cursor(): + while 1: + for cursor in '|/-\\': + yield cursor + + def __init__(self, delay=None): + self.spinner_generator = self.spinning_cursor() + if delay and float(delay): + self.delay = delay + + def spinner_task(self): + while self.busy: + sys.stdout.write(next(self.spinner_generator)) + sys.stdout.flush() + time.sleep(self.delay) + sys.stdout.write('\b') + sys.stdout.flush() + + def __enter__(self): + self.busy = True + threading.Thread(target=self.spinner_task).start() + + def __exit__(self, exception, value, tb): + self.busy = False + time.sleep(self.delay) + if exception is not None: + return False diff --git a/weirdlittleempire/management/serializers.py b/weirdlittleempire/management/serializers.py new file mode 100644 index 0000000..98e7b8e --- /dev/null +++ b/weirdlittleempire/management/serializers.py @@ -0,0 +1,68 @@ +""" +These serializers are used exclusively to import the file ``workdir/fixtures/products-meta.json``. +They are not intended for general purpose and can be deleted thereafter. +""" +from rest_framework import serializers +from shop.serializers.catalog import CMSPagesField, ImagesField, ValueRelatedField +from weirdlittleempire.models import (Commodity, SmartCard, SmartPhoneModel, SmartPhoneVariant, + Manufacturer, OperatingSystem, ProductPage, ProductImage) +from .translation import TranslatedFieldsField, TranslatedField, TranslatableModelSerializerMixin + + +class ProductSerializer(serializers.ModelSerializer): + product_model = serializers.CharField(read_only=True) + manufacturer = ValueRelatedField(model=Manufacturer) + images = ImagesField() + caption = TranslatedField() + cms_pages = CMSPagesField() + + class Meta: + exclude = ['id', 'polymorphic_ctype', 'updated_at'] + + def create(self, validated_data): + cms_pages = validated_data.pop('cms_pages') + images = validated_data.pop('images') + product = super().create(validated_data) + for page in cms_pages: + ProductPage.objects.create(product=product, page=page) + for image in images: + ProductImage.objects.create(product=product, image=image) + return product + + +class CommoditySerializer(TranslatableModelSerializerMixin, ProductSerializer): + + class Meta(ProductSerializer.Meta): + model = Commodity + exclude = ['id', 'placeholder', 'polymorphic_ctype', 'updated_at'] + + +class SmartCardSerializer(TranslatableModelSerializerMixin, ProductSerializer): + multilingual = TranslatedFieldsField( + help_text="Helper to convert multilingual data into single field.", + ) + + class Meta(ProductSerializer.Meta): + model = SmartCard + + +class SmartphoneVariantSerializer(serializers.ModelSerializer): + class Meta: + model = SmartPhoneVariant + fields = ['product_code', 'unit_price', 'storage', 'quantity'] + + +class SmartPhoneModelSerializer(TranslatableModelSerializerMixin, ProductSerializer): + multilingual = TranslatedFieldsField() + operating_system = ValueRelatedField(model=OperatingSystem) + variants = SmartphoneVariantSerializer(many=True) + + class Meta(ProductSerializer.Meta): + model = SmartPhoneModel + + def create(self, validated_data): + variants = validated_data.pop('variants') + product = super().create(validated_data) + for variant in variants: + SmartPhoneVariant.objects.create(product=product, **variant) + return product diff --git a/weirdlittleempire/management/translation.py b/weirdlittleempire/management/translation.py new file mode 100644 index 0000000..bd22afd --- /dev/null +++ b/weirdlittleempire/management/translation.py @@ -0,0 +1,73 @@ +""" +These serializer mixinins and fields are used exclusively to import the file +``workdir/fixtures/products-meta.json``. They are not intended for general +purpose and can be deleted thereafter. +""" +from rest_framework import serializers + + +class TranslatableModelSerializerMixin: + """ + Pseudo class mimicking the behaviour of :class:`parler_rest.TranslatableModelSerializerMixin`. + It converts the content for fields of type TranslatedFieldsField to simple serializer + fields. + """ + + def to_internal_value(self, data): + data = self._unify_translated_data(data) + result = super().to_internal_value(data) + return result + + def _unify_translated_data(self, data): + """ + Unify translated data to be used by simple serializer fields. + """ + for field_name, field in self.get_fields().items(): + if isinstance(field, TranslatedFieldsField): + key = field.source or field_name + translations = data.pop(key, None) + if isinstance(translations, dict): + data.update(translations.get('en', {})) + return data + + +class TranslatedFieldsField(serializers.Field): + """ + Pseudo class mimicking the behaviour of :class:`parler_rest.TranslatedFieldsField`, where only + the English translation is used. + """ + + def to_representation(self, value): + raise NotImplementedError( + "If USE_I18N is False, do not use {cls}.to_representation() for field '{field_name}'. " + "It thwarts the possibility to reuse that string in a multi language environment.".format( + cls=self.__class__.__name__, + field_name=self.field_name, + ) + ) + + def validate_empty_values(self, data): + raise serializers.SkipField() + + +class TranslatedField(serializers.Field): + """ + Pseudo class mimicking the behaviour of :class:`parler_rest.TranslatedField`, where only + the English translation is used. + """ + + def to_representation(self, value): + raise NotImplementedError( + "If USE_I18N is False, do not use {cls}.to_representation() for field '{field_name}'. " + "It thwarts the possibility to reuse that string in a multi language environment.".format( + cls=self.__class__.__name__, + field_name=self.field_name, + ) + ) + + def to_internal_value(self, data): + return data.get('en') + + +__all__ = ['TranslatedFieldsField', 'TranslatedField', + 'TranslatableModelSerializerMixin'] diff --git a/weirdlittleempire/migrations/__init__.py b/weirdlittleempire/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/weirdlittleempire/models.py b/weirdlittleempire/models.py new file mode 100644 index 0000000..63c4068 --- /dev/null +++ b/weirdlittleempire/models.py @@ -0,0 +1,405 @@ + +from decimal import Decimal +from django.core.exceptions import ObjectDoesNotExist +from django.core.validators import MinValueValidator +from django.db import models +from django.utils.translation import ugettext_lazy as _ +from djangocms_text_ckeditor.fields import HTMLField +from cms.models.fields import PlaceholderField +from shop.money import Money, MoneyMaker +from shop.money.fields import MoneyField +from shop.models.product import BaseProduct, BaseProductManager, AvailableProductMixin, CMSPageReferenceMixin +from shop.models.defaults.cart import Cart +from shop.models.defaults.cart_item import CartItem +from shop.models.order import BaseOrderItem +from shop.models.defaults.delivery import Delivery +from shop.models.defaults.delivery_item import DeliveryItem +from shop.models.defaults.order import Order +from shop.models.defaults.mapping import ProductPage, ProductImage +from shop.models.defaults.address import BillingAddress, ShippingAddress +from shop.models.defaults.customer import Customer + + +__all__ = ['Cart', 'CartItem', 'Order', 'Delivery', 'DeliveryItem', + 'BillingAddress', 'ShippingAddress', 'Customer', ] + + +class OrderItem(BaseOrderItem): + quantity = models.PositiveIntegerField(_("Ordered quantity")) + canceled = models.BooleanField(_("Item canceled "), default=False) + + def populate_from_cart_item(self, cart_item, request): + super().populate_from_cart_item(cart_item, request) + # the product's unit_price must be fetched from the product's variant + try: + variant = cart_item.product.get_product_variant( + product_code=cart_item.product_code) + self._unit_price = Decimal(variant.unit_price) + except (KeyError, ObjectDoesNotExist) as e: + raise CartItem.DoesNotExist(e) + + +class Manufacturer(models.Model): + name = models.CharField( + _("Name"), + max_length=50, + unique=True, + ) + + def __str__(self): + return self.name + + +class ProductManager(BaseProductManager): + pass + + +class Product(CMSPageReferenceMixin, BaseProduct): + """ + Base class to describe a polymorphic product. Here we declare common fields available in all of + our different product types. These common fields are also used to build up the view displaying + a list of all products. + """ + product_name = models.CharField( + _("Product Name"), + max_length=255, + ) + + slug = models.SlugField( + _("Slug"), + unique=True, + ) + + caption = HTMLField( + verbose_name=_("Caption"), + blank=True, + null=True, + configuration='CKEDITOR_SETTINGS_CAPTION', + help_text=_( + "Short description used in the catalog's list view of products."), + ) + + # common product properties + manufacturer = models.ForeignKey( + Manufacturer, + on_delete=models.CASCADE, + verbose_name=_("Manufacturer"), + ) + + # controlling the catalog + order = models.PositiveIntegerField( + _("Sort by"), + db_index=True, + ) + + cms_pages = models.ManyToManyField( + 'cms.Page', + through=ProductPage, + help_text=_("Choose list view this product shall appear on."), + ) + + images = models.ManyToManyField( + 'filer.Image', + through=ProductImage, + ) + + class Meta: + ordering = ('order',) + verbose_name = _("Product") + verbose_name_plural = _("Products") + + objects = ProductManager() + + # filter expression used to lookup for a product item using the Select2 widget + lookup_fields = ['product_name__icontains'] + + def __str__(self): + return self.product_name + + @property + def sample_image(self): + return self.images.first() + + +class Commodity(AvailableProductMixin, Product): + """ + This Commodity model inherits from polymorphic Product, and therefore has to be redefined. + """ + unit_price = MoneyField( + _("Unit price"), + decimal_places=3, + help_text=_("Net price for this product"), + ) + + product_code = models.CharField( + _("Product code"), + max_length=255, + unique=True, + ) + + quantity = models.PositiveIntegerField( + _("Quantity"), + default=0, + validators=[MinValueValidator(0)], + help_text=_("Available quantity in stock") + ) + + # controlling the catalog + placeholder = PlaceholderField("Commodity Details") + show_breadcrumb = True # hard coded to always show the product's breadcrumb + + class Meta: + verbose_name = _("Commodity") + verbose_name_plural = _("Commodities") + + default_manager = ProductManager() + + def get_price(self, request): + return self.unit_price + + +class SmartCard(AvailableProductMixin, Product): + unit_price = MoneyField( + _("Unit price"), + decimal_places=3, + help_text=_("Net price for this product"), + ) + + card_type = models.CharField( + _("Card Type"), + choices=[2 * ('{}{}'.format(s, t),) + for t in ['SD', 'SDXC', 'SDHC', 'SDHC II'] for s in ['', 'micro ']], + max_length=15, + ) + + speed = models.CharField( + _("Transfer Speed"), + choices=[(str(s), "{} MB/s".format(s)) + for s in [4, 20, 30, 40, 48, 80, 95, 280]], + max_length=8, + ) + + product_code = models.CharField( + _("Product code"), + max_length=255, + unique=True, + ) + + storage = models.PositiveIntegerField( + _("Storage Capacity"), + help_text=_("Storage capacity in GB"), + ) + + description = HTMLField( + _("Description"), + configuration='CKEDITOR_SETTINGS_DESCRIPTION', + help_text=_("Long description for the detail view of this product."), + ) + + quantity = models.PositiveIntegerField( + _("Quantity"), + default=0, + validators=[MinValueValidator(0)], + help_text=_("Available quantity in stock") + ) + + class Meta: + verbose_name = _("Smart Card") + verbose_name_plural = _("Smart Cards") + ordering = ['order'] + + # filter expression used to lookup for a product item using the Select2 widget + lookup_fields = ['product_code__startswith', 'product_name__icontains'] + + def get_price(self, request): + return self.unit_price + + default_manager = ProductManager() + + +class OperatingSystem(models.Model): + name = models.CharField( + _("Name"), + max_length=50, + unique=True, + ) + + def __str__(self): + return self.name + + +class SmartPhoneModel(Product): + """ + A generic smart phone model, which must be concretized by a `SmartPhoneVariant` - see below. + """ + BATTERY_TYPES = [ + (1, "Lithium Polymer (Li-Poly)"), + (2, "Lithium Ion (Li-Ion)"), + ] + WIFI_CONNECTIVITY = [ + (1, "802.11 b/g/n"), + ] + BLUETOOTH_CONNECTIVITY = [ + (1, "Bluetooth 4.0"), + (2, "Bluetooth 3.0"), + (3, "Bluetooth 2.1"), + ] + battery_type = models.PositiveSmallIntegerField( + _("Battery type"), + choices=BATTERY_TYPES, + ) + + battery_capacity = models.PositiveIntegerField( + _("Capacity"), + help_text=_("Battery capacity in mAh"), + ) + + ram_storage = models.PositiveIntegerField( + _("RAM"), + help_text=_("RAM storage in MB"), + ) + + wifi_connectivity = models.PositiveIntegerField( + _("WiFi"), + choices=WIFI_CONNECTIVITY, + help_text=_("WiFi Connectivity"), + ) + + bluetooth = models.PositiveIntegerField( + _("Bluetooth"), + choices=BLUETOOTH_CONNECTIVITY, + help_text=_("Bluetooth Connectivity"), + ) + + gps = models.BooleanField( + _("GPS"), + default=False, + help_text=_("GPS integrated"), + ) + + operating_system = models.ForeignKey( + OperatingSystem, + on_delete=models.CASCADE, + verbose_name=_("Operating System"), + ) + + width = models.DecimalField( + _("Width"), + max_digits=4, + decimal_places=1, + help_text=_("Width in mm"), + ) + + height = models.DecimalField( + _("Height"), + max_digits=4, + decimal_places=1, + help_text=_("Height in mm"), + ) + + weight = models.DecimalField( + _("Weight"), + max_digits=5, + decimal_places=1, + help_text=_("Weight in gram"), + ) + + screen_size = models.DecimalField( + _("Screen size"), + max_digits=4, + decimal_places=2, + help_text=_("Diagonal screen size in inch"), + ) + + description = HTMLField( + verbose_name=_("Description"), + configuration='CKEDITOR_SETTINGS_DESCRIPTION', + help_text=_( + "Full description used in the catalog's detail view of Smart Phones."), + ) + + class Meta: + verbose_name = _("Smart Phone") + verbose_name_plural = _("Smart Phones") + + default_manager = ProductManager() + + def get_price(self, request): + """ + Return the starting price for instances of this smart phone model. + """ + if not hasattr(self, '_price'): + if self.variants.exists(): + currency = self.variants.first().unit_price.currency + aggr = self.variants.aggregate(models.Min('unit_price')) + self._price = MoneyMaker(currency)(aggr['unit_price__min']) + else: + self._price = Money() + return self._price + + def get_availability(self, request, **kwargs): + variant = self.get_product_variant(**kwargs) + return variant.get_availability(request) + + def deduct_from_stock(self, quantity, **kwargs): + variant = self.get_product_variant(**kwargs) + variant.deduct_from_stock(quantity) + + def is_in_cart(self, cart, watched=False, **kwargs): + try: + product_code = kwargs['product_code'] + except KeyError: + return + cart_item_qs = CartItem.objects.filter(cart=cart, product=self) + for cart_item in cart_item_qs: + if cart_item.product_code == product_code: + return cart_item + + def get_product_variant(self, **kwargs): + try: + product_code = kwargs.get('product_code') + return self.variants.get(product_code=product_code) + except SmartPhoneVariant.DoesNotExist as e: + raise SmartPhoneModel.DoesNotExist(e) + + def get_product_variants(self): + return self.variants.all() + + +class SmartPhoneVariant(AvailableProductMixin, models.Model): + product = models.ForeignKey( + SmartPhoneModel, + on_delete=models.CASCADE, + verbose_name=_("Smartphone Model"), + related_name='variants', + ) + + product_code = models.CharField( + _("Product code"), + max_length=255, + unique=True, + ) + + unit_price = MoneyField( + _("Unit price"), + decimal_places=3, + help_text=_("Net price for this product"), + ) + + storage = models.PositiveIntegerField( + _("Internal Storage"), + help_text=_("Internal storage in GB"), + ) + + quantity = models.PositiveIntegerField( + _("Quantity"), + default=0, + validators=[MinValueValidator(0)], + help_text=_("Available quantity in stock") + ) + + def __str__(self): + return _("{product} with {storage} GB").format(product=self.product, storage=self.storage) + + def get_price(self, request): + return self.unit_price diff --git a/weirdlittleempire/modifiers.py b/weirdlittleempire/modifiers.py new file mode 100644 index 0000000..891e25b --- /dev/null +++ b/weirdlittleempire/modifiers.py @@ -0,0 +1,52 @@ +from django.core.exceptions import ValidationError +from django.utils.translation import ugettext_lazy as _ +from shop.modifiers.pool import cart_modifiers_pool +from shop.modifiers.defaults import DefaultCartModifier +from shop.serializers.cart import ExtraCartRow +from shop.money import Money +from shop.shipping.modifiers import ShippingModifier +from shop_stripe import modifiers + + +class PrimaryCartModifier(DefaultCartModifier): + """ + Extended default cart modifier which handles the price for product variations + """ + + def process_cart_item(self, cart_item, request): + variant = cart_item.product.get_product_variant( + product_code=cart_item.product_code) + cart_item.unit_price = variant.unit_price + cart_item.line_total = cart_item.unit_price * cart_item.quantity + # grandparent super + return super(DefaultCartModifier, self).process_cart_item(cart_item, request) + + +class PostalShippingModifier(ShippingModifier): + """ + This is just a demo on how to implement a shipping modifier, which when selected + by the customer, adds an additional charge to the cart. + """ + identifier = 'postal-shipping' + + def get_choice(self): + return (self.identifier, _("Postal shipping")) + + def add_extra_cart_row(self, cart, request): + shipping_modifiers = cart_modifiers_pool.get_shipping_modifiers() + if not self.is_active(cart.extra.get('shipping_modifier')) and len(shipping_modifiers) > 1: + return + # add a shipping flat fee + amount = Money('5') + instance = {'label': _("Shipping costs"), 'amount': amount} + cart.extra_rows[self.identifier] = ExtraCartRow(instance) + cart.total += amount + + def ship_the_goods(self, delivery): + if not delivery.shipping_id: + raise ValidationError("Please provide a valid Shipping ID") + super().ship_the_goods(delivery) + + +class StripePaymentModifier(modifiers.StripePaymentModifier): + commision_percentage = 3 diff --git a/weirdlittleempire/search_indexes.py b/weirdlittleempire/search_indexes.py new file mode 100644 index 0000000..00b3064 --- /dev/null +++ b/weirdlittleempire/search_indexes.py @@ -0,0 +1,8 @@ + +from shop.search.documents import ProductDocument + +settings = { + 'number_of_shards': 1, + 'number_of_replicas': 0, +} +ProductDocument(settings=settings) diff --git a/weirdlittleempire/serializers.py b/weirdlittleempire/serializers.py new file mode 100644 index 0000000..b59da79 --- /dev/null +++ b/weirdlittleempire/serializers.py @@ -0,0 +1,31 @@ + +from shop.models.cart import CartModel +from shop.serializers.defaults.catalog import AddToCartSerializer + + +class AddSmartPhoneToCartSerializer(AddToCartSerializer): + """ + Modified AddToCartSerializer which handles SmartPhones + """ + + def get_instance(self, context, data, extra_args): + product = context['product'] + request = context['request'] + try: + cart = CartModel.objects.get_from_request(request) + except CartModel.DoesNotExist: + cart = None + try: + variant = product.get_product_variant( + product_code=data['product_code']) + except (TypeError, KeyError, product.DoesNotExist): + variant = product.variants.first() + instance = { + 'product': product.id, + 'product_code': variant.product_code, + 'unit_price': variant.unit_price, + 'is_in_cart': bool(product.is_in_cart(cart, product_code=variant.product_code)), + 'extra': {'storage': variant.storage}, + 'availability': variant.get_availability(request), + } + return instance diff --git a/weirdlittleempire/settings.py b/weirdlittleempire/settings.py new file mode 100644 index 0000000..94182cc --- /dev/null +++ b/weirdlittleempire/settings.py @@ -0,0 +1,598 @@ +""" +Django settings for weirdlittleempire project. + +For more information on this file, see +https://docs.djangoproject.com/en/stable/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/stable/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +from decimal import Decimal +import os +from django.urls import reverse_lazy +from django.utils.text import format_lazy +from django.utils.translation import ugettext_lazy as _ +from cmsplugin_cascade.bootstrap4.mixins import BootstrapUtilities +from cmsplugin_cascade.extra_fields.config import PluginExtraFieldsConfig + +SHOP_APP_LABEL = 'weirdlittleempire' +BASE_DIR = os.path.dirname(__file__) + +# Root directory for this django project +PROJECT_ROOT = os.path.abspath(os.path.join(BASE_DIR, os.path.pardir)) + +# Directory where working files, such as media and databases are kept +WORK_DIR = os.environ.get('DJANGO_WORKDIR', os.path.abspath( + os.path.join(PROJECT_ROOT, 'workdir'))) + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ + +ADMINS = [("A Jones", 'biz@aronajones.com')] + +# SECURITY WARNING: in production, inject the secret key through the environment +SECRET_KEY = os.environ.get( + 'DJANGO_SECRET_KEY', 'Q1ayyKMNv4figvm1DDseLjWlOHn4OI7lW2hxNn0BztgWkXJLBTFDkYJCmY2OshPt') + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] + +SITE_ID = 1 + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# On Unix systems, a value of None will cause Django to use the same +# timezone as the operating system. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'GMT' + +USE_THOUSAND_SEPARATOR = True + +# Application definition + +# replace django.contrib.auth.models.User by implementation +# allowing to login via email address +AUTH_USER_MODEL = 'email_auth.User' + +AUTH_PASSWORD_VALIDATORS = [{ + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + 'OPTIONS': { + 'min_length': 6, + } +}] + +AUTHENTICATION_BACKENDS = [ + 'django.contrib.auth.backends.ModelBackend', + 'allauth.account.auth_backends.AuthenticationBackend', +] + +INSTALLED_APPS = [ + 'django.contrib.auth', + 'email_auth', + 'polymorphic', + # deprecated: 'djangocms_admin_style', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.admin', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django.contrib.sitemaps', + 'djangocms_text_ckeditor', + 'django_select2', + 'cmsplugin_cascade', + 'cmsplugin_cascade.clipboard', + 'cmsplugin_cascade.sharable', + 'cmsplugin_cascade.extra_fields', + 'cmsplugin_cascade.icon', + 'cmsplugin_cascade.segmentation', + 'cms_bootstrap', + 'adminsortable2', + 'rest_framework', + 'rest_framework.authtoken', + 'rest_auth', + 'django_elasticsearch_dsl', + 'django_fsm', + 'fsm_admin', + 'djng', + 'cms', + 'menus', + 'treebeard', + 'compressor', + 'sass_processor', + 'sekizai', + 'django_filters', + 'filer', + 'easy_thumbnails', + 'easy_thumbnails.optimize', + 'post_office', + 'shop_stripe', + 'shop', + 'weirdlittleempire', +] + +MIDDLEWARE = [ + # 'django.middleware.cache.UpdateCacheMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'shop.middleware.CustomerMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.locale.LocaleMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.gzip.GZipMiddleware', + 'cms.middleware.language.LanguageCookieMiddleware', + 'cms.middleware.user.CurrentUserMiddleware', + 'cms.middleware.page.CurrentPageMiddleware', + 'cms.middleware.utils.ApphookReloadMiddleware', + 'cms.middleware.toolbar.ToolbarMiddleware', + # 'django.middleware.cache.FetchFromCacheMiddleware', +] + +ROOT_URLCONF = 'weirdlittleempire.urls' + +WSGI_APPLICATION = 'wsgi.application' + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(WORK_DIR, 'db.sqlite3'), + } +} + +# Internationalization +# https://docs.djangoproject.com/en/stable/topics/i18n/ + +LANGUAGE_CODE = 'en' + +USE_I18N = False +USE_L10N = True + +USE_TZ = True + +USE_X_FORWARDED_HOST = True + +X_FRAME_OPTIONS = 'SAMEORIGIN' + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = os.path.join(WORK_DIR, 'media') + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash. +# Examples: "http://media.lawrence.com/media/", "http://example.com/media/" +MEDIA_URL = '/media/' + +# Absolute path to the directory that holds static files. +# Example: "/home/media/media.lawrence.com/static/" +STATIC_ROOT = os.getenv('DJANGO_STATIC_ROOT', os.path.join(WORK_DIR, 'static')) + +# URL that handles the static files served from STATIC_ROOT. +# Example: "http://media.lawrence.com/static/" +STATIC_URL = '/static/' + +STATICFILES_FINDERS = [ + # or 'django.contrib.staticfiles.finders.FileSystemFinder', + 'weirdlittleempire.finders.FileSystemFinder', + # or 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + 'weirdlittleempire.finders.AppDirectoriesFinder', + 'sass_processor.finders.CssFinder', + 'compressor.finders.CompressorFinder', +] + +STATICFILES_DIRS = [ + ('node_modules', os.path.join(PROJECT_ROOT, 'node_modules')), +] + +TEMPLATES = [{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'APP_DIRS': True, + 'DIRS': [], + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.template.context_processors.csrf', + 'django.template.context_processors.request', + 'django.contrib.messages.context_processors.messages', + 'sekizai.context_processors.sekizai', + 'cms.context_processors.cms_settings', + 'shop.context_processors.customer', + 'shop.context_processors.shop_settings', + 'shop_stripe.context_processors.public_keys', + ] + } +}, { + 'BACKEND': 'post_office.template.backends.post_office.PostOfficeTemplates', + 'APP_DIRS': True, + 'DIRS': [], + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.template.context_processors.request', + ] + } +}] + +POST_OFFICE = { + 'TEMPLATE_ENGINE': 'post_office', +} + +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + }, + 'select2': { + 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', + } +} + +############################################ +# settings for caching and storing session data +REDIS_HOST = os.getenv('REDIS_HOST') +if REDIS_HOST: + SESSION_ENGINE = 'redis_sessions.session' + + SESSION_REDIS = { + 'host': REDIS_HOST, + 'port': 6379, + 'db': 0, + 'prefix': 'session-', + 'socket_timeout': 1 + } + + CACHES['default'] = { + 'BACKEND': 'redis_cache.RedisCache', + 'LOCATION': 'redis://{}:6379/1'.format(REDIS_HOST), + } + + COMPRESS_CACHE_BACKEND = 'compressor' + CACHES[COMPRESS_CACHE_BACKEND] = { + 'BACKEND': 'redis_cache.RedisCache', + 'LOCATION': 'redis://{}:6379/2'.format(REDIS_HOST), + } + + CACHE_MIDDLEWARE_ALIAS = 'default' + CACHE_MIDDLEWARE_SECONDS = 3600 +else: + SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' + +SESSION_SAVE_EVERY_REQUEST = True + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': True, + 'filters': {'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'}}, + 'formatters': { + 'simple': { + 'format': '[%(asctime)s %(module)s] %(levelname)s: %(message)s' + }, + }, + 'handlers': { + 'console': { + 'level': 'INFO', + 'class': 'logging.StreamHandler', + 'formatter': 'simple', + }, + }, + 'loggers': { + 'django': { + 'handlers': ['console'], + 'level': 'INFO', + 'propagate': True, + }, + 'post_office': { + 'handlers': ['console'], + 'level': 'WARNING', + 'propagate': True, + }, + }, +} + +SILENCED_SYSTEM_CHECKS = ['auth.W004'] + +FIXTURE_DIRS = [ + os.path.join(WORK_DIR, 'fixtures'), +] + +############################################ +# settings for sending mail + +EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', 'localhost') +EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 25) +EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_USER', 'no-reply@localhost') +EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_PASSWORD', 'smtp-secret') +EMAIL_USE_TLS = bool(os.getenv('DJANGO_EMAIL_USE_TLS', '1')) +DEFAULT_FROM_EMAIL = os.getenv('DJANGO_EMAIL_FROM', 'no-reply@localhost') +EMAIL_REPLY_TO = os.getenv('DJANGO_EMAIL_REPLY_TO', 'info@localhost') +EMAIL_BACKEND = 'post_office.EmailBackend' + + +############################################ +# settings for third party Django apps + +NODE_MODULES_URL = STATIC_URL + 'node_modules/' + +SASS_PROCESSOR_INCLUDE_DIRS = [ + os.path.join(PROJECT_ROOT, 'node_modules'), +] + +COERCE_DECIMAL_TO_STRING = True + +FSM_ADMIN_FORCE_PERMIT = True + +ROBOTS_META_TAGS = ('noindex', 'nofollow') + +SERIALIZATION_MODULES = {'json': str('shop.money.serializers')} + +############################################ +# settings for django-restframework and plugins + +REST_FRAMEWORK = { + 'DEFAULT_RENDERER_CLASSES': [ + 'shop.rest.money.JSONRenderer', + # can be disabled for production environments + 'rest_framework.renderers.BrowsableAPIRenderer', + ], + 'DEFAULT_FILTER_BACKENDS': [ + 'django_filters.rest_framework.DjangoFilterBackend', + ], + # 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', + # 'PAGE_SIZE': 16, +} + +REST_AUTH_SERIALIZERS = { + 'LOGIN_SERIALIZER': 'shop.serializers.auth.LoginSerializer', +} + +############################################ +# settings for storing files and images + +FILER_ADMIN_ICON_SIZES = ('16', '32', '48', '80', '128') + +FILER_ALLOW_REGULAR_USERS_TO_ADD_ROOT_FOLDERS = True + +FILER_DUMP_PAYLOAD = False + +FILE_UPLOAD_MAX_MEMORY_SIZE = 5242880 + +THUMBNAIL_HIGH_RESOLUTION = False + +THUMBNAIL_PRESERVE_EXTENSIONS = True + +THUMBNAIL_PROCESSORS = ( + 'easy_thumbnails.processors.colorspace', + 'easy_thumbnails.processors.autocrop', + 'filer.thumbnail_processors.scale_and_crop_with_subject_location', + 'easy_thumbnails.processors.filters', +) + + +############################################ +# settings for django-cms and its plugins + +CMS_TEMPLATES = [ + ('weirdlittleempire/pages/default.html', "Default Page"), +] + +CMS_CACHE_DURATIONS = { + 'content': 600, + 'menus': 3600, + 'permissions': 86400, +} + +CMS_PERMISSION = True + +CMS_PLACEHOLDER_CONF = { + 'Breadcrumb': { + 'plugins': ['BreadcrumbPlugin'], + 'parent_classes': {'BreadcrumbPlugin': None}, + }, + 'Commodity Details': { + 'plugins': ['BootstrapContainerPlugin', 'BootstrapJumbotronPlugin'], + 'parent_classes': { + 'BootstrapContainerPlugin': None, + 'BootstrapJumbotronPlugin': None, + }, + }, + 'Main Content': { + 'plugins': ['BootstrapContainerPlugin', 'BootstrapJumbotronPlugin'], + 'parent_classes': { + 'BootstrapContainerPlugin': None, + 'BootstrapJumbotronPlugin': None, + 'TextLinkPlugin': ['TextPlugin', 'AcceptConditionPlugin'], + }, + }, + 'Static Footer': { + 'plugins': ['BootstrapContainerPlugin', 'BootstrapJumbotronPlugin'], + 'parent_classes': { + 'BootstrapContainerPlugin': None, + 'BootstrapJumbotronPlugin': None, + }, + }, +} + +CMSPLUGIN_CASCADE_PLUGINS = [ + 'cmsplugin_cascade.bootstrap4', + 'cmsplugin_cascade.segmentation', + 'cmsplugin_cascade.generic', + 'cmsplugin_cascade.icon', + 'cmsplugin_cascade.leaflet', + 'cmsplugin_cascade.link', + 'shop.cascade', +] + +CMSPLUGIN_CASCADE = { + 'link_plugin_classes': [ + 'shop.cascade.plugin_base.CatalogLinkPluginBase', + 'shop.cascade.plugin_base.CatalogLinkForm', + ], + 'alien_plugins': ['TextPlugin', 'TextLinkPlugin', 'AcceptConditionPlugin'], + 'bootstrap4': { + 'template_basedir': 'angular-ui/', + }, + 'plugins_with_extra_render_templates': { + 'CustomSnippetPlugin': [ + ('shop/catalog/product-heading.html', _("Product Heading")), + ('weirdlittleempire/catalog/manufacturer-filter.html', + _("Manufacturer Filter")), + ], + # required to purchase real estate + 'ShopAddToCartPlugin': [ + (None, _("Default")), + ('weirdlittleempire/catalog/commodity-add2cart.html', + _("Add Commodity to Cart")), + ], + }, + 'plugins_with_sharables': { + 'BootstrapImagePlugin': ['image_shapes', 'image_width_responsive', 'image_width_fixed', + 'image_height', 'resize_options'], + 'BootstrapPicturePlugin': ['image_shapes', 'responsive_heights', 'responsive_zoom', 'resize_options'], + }, + 'plugins_with_extra_fields': { + 'BootstrapCardPlugin': PluginExtraFieldsConfig(), + 'BootstrapCardHeaderPlugin': PluginExtraFieldsConfig(), + 'BootstrapCardBodyPlugin': PluginExtraFieldsConfig(), + 'BootstrapCardFooterPlugin': PluginExtraFieldsConfig(), + 'SimpleIconPlugin': PluginExtraFieldsConfig(), + }, + 'plugins_with_extra_mixins': { + 'BootstrapContainerPlugin': BootstrapUtilities(), + 'BootstrapRowPlugin': BootstrapUtilities(BootstrapUtilities.paddings), + 'BootstrapYoutubePlugin': BootstrapUtilities(BootstrapUtilities.margins), + 'BootstrapButtonPlugin': BootstrapUtilities(BootstrapUtilities.floats), + }, + 'leaflet': { + 'tilesURL': 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', + 'accessToken': 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', + 'apiKey': 'AIzaSyD71sHrtkZMnLqTbgRmY_NsO0A9l9BQmv4', + }, + 'bookmark_prefix': '/', + 'segmentation_mixins': [ + ('shop.cascade.segmentation.EmulateCustomerModelMixin', + 'shop.cascade.segmentation.EmulateCustomerAdminMixin'), + ], + 'allow_plugin_hiding': True, + 'register_page_editor': True, +} + +CKEDITOR_SETTINGS = { + 'language': '{{ language }}', + 'skin': 'moono-lisa', + 'toolbar_CMS': [ + ['Undo', 'Redo'], + ['cmsplugins', '-', 'ShowBlocks'], + ['Format'], + ['TextColor', 'BGColor', '-', 'PasteText', 'PasteFromWord'], + '/', + ['Bold', 'Italic', 'Underline', 'Strike', '-', + 'Subscript', 'Superscript', '-', 'RemoveFormat'], + ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], + ['HorizontalRule'], + ['NumberedList', 'BulletedList', 'Outdent', 'Indent'], + ['Table', 'Source'] + ], + 'stylesSet': format_lazy('default:{}', reverse_lazy('admin:cascade_texteditor_config')), +} + +CKEDITOR_SETTINGS_CAPTION = { + 'language': '{{ language }}', + 'skin': 'moono-lisa', + 'height': 70, + 'toolbar_HTMLField': [ + ['Undo', 'Redo'], + ['Format', 'Styles'], + ['Bold', 'Italic', 'Underline', '-', 'Subscript', + 'Superscript', '-', 'RemoveFormat'], + ['Source'] + ], +} + +CKEDITOR_SETTINGS_DESCRIPTION = { + 'language': '{{ language }}', + 'skin': 'moono-lisa', + 'height': 250, + 'toolbar_HTMLField': [ + ['Undo', 'Redo'], + ['cmsplugins', '-', 'ShowBlocks'], + ['Format', 'Styles'], + ['TextColor', 'BGColor', '-', 'PasteText', 'PasteFromWord'], + ['Maximize', ''], + '/', + ['Bold', 'Italic', 'Underline', '-', 'Subscript', + 'Superscript', '-', 'RemoveFormat'], + ['JustifyLeft', 'JustifyCenter', 'JustifyRight'], + ['HorizontalRule'], + ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent'], + ['Source'] + ], +} + +SELECT2_CSS = 'node_modules/select2/dist/css/select2.min.css' +SELECT2_JS = 'node_modules/select2/dist/js/select2.min.js' +SELECT2_I18N_PATH = 'node_modules/select2/dist/js/i18n' + + +############################################# +# settings for full index text search + +ELASTICSEARCH_HOST = os.getenv('ELASTICSEARCH_HOST', 'localhost') + +ELASTICSEARCH_DSL = { + 'default': { + 'hosts': '{}:9200'.format(ELASTICSEARCH_HOST) + }, +} + +############################################ +# settings for django-shop and its plugins + +SHOP_VALUE_ADDED_TAX = Decimal(19) +SHOP_DEFAULT_CURRENCY = 'EUR' +SHOP_EDITCART_NG_MODEL_OPTIONS = "{updateOn: 'default blur', debounce: {'default': 2500, 'blur': 0}}" + +SHOP_CART_MODIFIERS = [ + 'weirdlittleempire.modifiers.PrimaryCartModifier', + 'shop.modifiers.taxes.CartExcludedTaxModifier', + 'weirdlittleempire.modifiers.PostalShippingModifier', + 'weirdlittleempire.modifiers.StripePaymentModifier', + 'shop.payment.modifiers.PayInAdvanceModifier', + 'shop.shipping.modifiers.SelfCollectionModifier', +] + +SHOP_ORDER_WORKFLOWS = [ + 'shop.payment.workflows.ManualPaymentWorkflowMixin', + 'shop.payment.workflows.CancelOrderWorkflowMixin', + 'shop.shipping.workflows.PartialDeliveryWorkflowMixin', + 'shop_stripe.workflows.OrderWorkflowMixin', +] + + +SHOP_STRIPE = { + 'PUBKEY': os.getenv('STRIPE_PUBKEY', 'pk_test_HlEp5oZyPonE21svenqowhXp'), + 'APIKEY': os.getenv('STRIPE_APIKEY', 'sk_test_xUdHLeFasmOUDvmke4DHGRDP'), + 'PURCHASE_DESCRIPTION': _("Thanks for purchasing at Weird Little Empire"), +} +SHOP_STRIPE_PREFILL = True + + +SHOP_CASCADE_FORMS = { + 'CustomerForm': 'weirdlittleempire.forms.CustomerForm', +} diff --git a/weirdlittleempire/sitemap.py b/weirdlittleempire/sitemap.py new file mode 100644 index 0000000..02f83f5 --- /dev/null +++ b/weirdlittleempire/sitemap.py @@ -0,0 +1,12 @@ +from django.contrib.sitemaps import Sitemap +from django.conf import settings +from weirdlittleempire.models import Product + + +class ProductSitemap(Sitemap): + changefreq = 'monthly' + priority = 0.5 + i18n = settings.USE_I18N + + def items(self): + return Product.objects.filter(active=True) diff --git a/weirdlittleempire/static/weirdlittleempire/css/_footer.scss b/weirdlittleempire/static/weirdlittleempire/css/_footer.scss new file mode 100644 index 0000000..dd590b9 --- /dev/null +++ b/weirdlittleempire/static/weirdlittleempire/css/_footer.scss @@ -0,0 +1,35 @@ +@import "variables"; + +html { + height: 100%; + &.cms-toolbar-expanded { + // prevents pushing a sticky footer outside the vertical viewport if CMS toolbar is active + height: calc(100% - 46px); + } +} +body { + display: flex; + height: 100%; + flex-direction: column; + main { + flex: 1 0 auto; + padding-bottom: $body-footer-margin; + } + footer { + flex-shrink: 0; + color: $body-footer-color; + background: $body-footer-bg; + padding-top: $body-footer-margin; + padding-bottom: $body-footer-margin; + a { + color: $body-footer-link-color; + text-decoration: none; + &:hover { + color: $body-footer-link-hover-color; + } + &:active { + color: $body-footer-link-active-color; + } + } + } +} diff --git a/weirdlittleempire/static/weirdlittleempire/css/_navbar.scss b/weirdlittleempire/static/weirdlittleempire/css/_navbar.scss new file mode 100644 index 0000000..7907490 --- /dev/null +++ b/weirdlittleempire/static/weirdlittleempire/css/_navbar.scss @@ -0,0 +1,103 @@ +@import "variables"; +@import "shop/css/navbar"; + +body { + padding-top: $body-header-height; + @include media-breakpoint-up(lg) { + padding-top: $body-header-lg-height; + } + .navbar { + $navbar: &; + @include media-breakpoint-up(lg) { + height: $body-header-lg-height; + transition: height 500ms ease, box-shadow 250ms ease; + padding-top: 0; + padding-bottom: 0; + .navbar-nav, .navbar-collapse, >.container { + height: 100% !important; + } + &.scrolled { + height: 75px; + box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.075); + .shop-brand-icon { + height: 32px; + } + } + .nav-link { + padding-top: 0.25rem; + padding-bottom: 0.25rem; + } + } + .shop-brand-icon { + height: 48px; + transition: height 500ms ease; + position: absolute; + padding-top: 0.5rem; + top: 0; + left: 0; + right: 0; + display: flex; + justify-content: center; + pointer-events: none; + a { + width: min-content; + } + img { + height: 100%; + width: auto; + margin: auto; + display: block; + pointer-events: auto; + } + } + .shop-social-icons { + .nav-link { + display: inline-block; + padding-left: 0.25rem; + padding-right: 0.25rem; + } + @include media-breakpoint-down(md) { + order: 4; + .nav-link { + margin-left: 0.25rem; + margin-right: 0.5rem; + } + } + @include media-breakpoint-up(lg) { + align-self: flex-end; + } + .cms-placeholder { + display: inline-block; + } + } + .shop-primary-menu { + font-size: 125%; + font-weight: 300; + @include media-breakpoint-down(md) { + order: 1; + } + @include media-breakpoint-up(lg) { + font-size: 150%; + .dropdown-toggle::after { + font-size: initial; + } + } + } + .shop-secondary-menu { + @include media-breakpoint-down(md) { + order: 2; + } + @include media-breakpoint-up(lg) { + align-self: flex-end; + } + } + .shop-search-form { + @include media-breakpoint-down(md) { + order: 3; + } + @include media-breakpoint-up(lg) { + margin-left: auto; + } + } + } +} diff --git a/weirdlittleempire/static/weirdlittleempire/css/_variables.scss b/weirdlittleempire/static/weirdlittleempire/css/_variables.scss new file mode 100644 index 0000000..fbd69cc --- /dev/null +++ b/weirdlittleempire/static/weirdlittleempire/css/_variables.scss @@ -0,0 +1,14 @@ +@import "shop/css/variables"; + +// header +$body-header-height: 50px; +$body-header-lg-height: 90px; + +// footer +$body-footer-margin: 1rem; +$body-footer-color: $white; +$body-footer-bg: $gray-900; +$body-footer-border: $gray-900; +$body-footer-link-color: darken($body-footer-color, 15%); +$body-footer-link-hover-color: $body-footer-color; +$body-footer-link-active-color: $body-footer-color; diff --git a/weirdlittleempire/static/weirdlittleempire/css/default.scss b/weirdlittleempire/static/weirdlittleempire/css/default.scss new file mode 100644 index 0000000..a979699 --- /dev/null +++ b/weirdlittleempire/static/weirdlittleempire/css/default.scss @@ -0,0 +1,5 @@ +@import "variables"; +@import "font-awesome/scss/font-awesome"; +@import "shop/css/django-shop"; +@import "navbar"; +@import "footer"; diff --git a/weirdlittleempire/static/weirdlittleempire/django-shop-logo.png b/weirdlittleempire/static/weirdlittleempire/django-shop-logo.png new file mode 100644 index 0000000..7a32e76 Binary files /dev/null and b/weirdlittleempire/static/weirdlittleempire/django-shop-logo.png differ diff --git a/weirdlittleempire/static/weirdlittleempire/django-shop-logo.svg b/weirdlittleempire/static/weirdlittleempire/django-shop-logo.svg new file mode 100644 index 0000000..1acd8a6 --- /dev/null +++ b/weirdlittleempire/static/weirdlittleempire/django-shop-logo.svg @@ -0,0 +1,90 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/weirdlittleempire/static/weirdlittleempire/strides/checkout.json b/weirdlittleempire/static/weirdlittleempire/strides/checkout.json new file mode 100644 index 0000000..8913216 --- /dev/null +++ b/weirdlittleempire/static/weirdlittleempire/strides/checkout.json @@ -0,0 +1,695 @@ +{ + "plugins":[ + [ + "BootstrapContainerPlugin", + { + "glossary":{ + "media_queries":{ + "xs":[ + "(max-width: 768px)" + ], + "lg":[ + "(min-width: 1200px)" + ], + "sm":[ + "(min-width: 768px)", + "(max-width: 992px)" + ], + "md":[ + "(min-width: 992px)", + "(max-width: 1200px)" + ] + }, + "container_max_widths":{ + "xs":750, + "lg":1170, + "sm":750, + "md":970 + }, + "extra_inline_styles:Paddings":{ + "padding-top":"", + "padding-bottom":"30px" + }, + "fluid":"", + "breakpoints":[ + "xs", + "sm", + "md", + "lg" + ] + }, + "pk":14488 + }, + [ + [ + "SegmentPlugin", + { + "glossary":{ + "open_tag":"if", + "condition":"customer.is_recognized" + }, + "pk":14489 + }, + [ + [ + "BootstrapRowPlugin", + { + "glossary":{ + "extra_css_classes":[ + "foo", + "bar", + "cap" + ], + "hide_plugin":"", + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"20px" + } + }, + "pk":14490 + }, + [ + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "sm-responsive-utils":"", + "xs-responsive-utils":"", + "md-column-offset":"", + "sm-column-width":"col-sm-10", + "md-responsive-utils":"", + "xs-column-offset":"", + "sm-column-offset":"col-sm-offset-1", + "sm-column-ordering":"", + "md-column-ordering":"", + "lg-column-ordering":"", + "lg-column-offset":"col-lg-offset-2", + "md-column-width":"", + "xs-column-width":"col-xs-12", + "lg-responsive-utils":"", + "container_max_widths":{ + "xs":720.0, + "lg":750.0, + "sm":595.0, + "md":778.33 + }, + "lg-column-width":"col-lg-8", + "xs-column-ordering":"" + }, + "pk":14491 + }, + [ + [ + "ProcessBarPlugin", + { + "glossary":{}, + "pk":14492 + }, + [ + [ + "ProcessStepPlugin", + { + "glossary":{ + "hide_plugin":"", + "step_title":"Addresses" + }, + "pk":14500 + }, + [ + [ + "CheckoutAddressPlugin", + { + "glossary":{ + "allow_use_primary":"", + "allow_multiple":"on", + "address_form":"shipping", + "render_type":"form", + "hide_plugin":"", + "headline_legend":"on" + }, + "pk":14503 + }, + [] + ], + [ + "CheckoutAddressPlugin", + { + "glossary":{ + "allow_use_primary":"on", + "allow_multiple":"on", + "address_form":"billing", + "render_type":"form", + "hide_plugin":"", + "headline_legend":"on" + }, + "pk":14504 + }, + [] + ], + [ + "RequiredFormFieldsPlugin", + { + "glossary":{}, + "pk":14502 + }, + [] + ], + [ + "ProcessNextStepPlugin", + { + "glossary":{ + "icon_align":"icon-right", + "symbol":"right-open", + "button_size":"", + "quick_float":"pull-right", + "button_options":[], + "icon_font":"4", + "link_content":"Next", + "button_type":"btn-success", + "hide_plugin":"" + }, + "pk":14501 + }, + [] + ] + ] + ], + [ + "ProcessStepPlugin", + { + "glossary":{ + "step_title":"Customer" + }, + "pk":14493 + }, + [ + [ + "SegmentPlugin", + { + "glossary":{ + "open_tag":"if", + "condition":"customer.is_registered" + }, + "pk":14494 + }, + [ + [ + "CustomerFormPlugin", + { + "glossary":{ + "render_type":"form" + }, + "pk":14495 + }, + [] + ] + ] + ], + [ + "SegmentPlugin", + { + "glossary":{ + "open_tag":"else", + "condition":"" + }, + "pk":14496 + }, + [ + [ + "GuestFormPlugin", + { + "glossary":{ + "render_type":"form" + }, + "pk":14497 + }, + [] + ] + ] + ], + [ + "RequiredFormFieldsPlugin", + { + "glossary":{}, + "pk":14499 + }, + [] + ], + [ + "ProcessNextStepPlugin", + { + "glossary":{ + "icon_align":"icon-right", + "symbol":"right-open", + "button_size":"", + "quick_float":"pull-right", + "button_options":[], + "icon_font":"4", + "link_content":"Next", + "button_type":"btn-success", + "hide_plugin":"" + }, + "pk":14498 + }, + [] + ] + ] + ], + [ + "ProcessStepPlugin", + { + "glossary":{ + "hide_plugin":"", + "step_title":"Payment" + }, + "pk":14505 + }, + [ + [ + "HeadingPlugin", + { + "glossary":{ + "content":"Bezahlen und Versenden", + "element_id":"", + "tag_type":"h3" + }, + "pk":14512 + }, + [] + ], + [ + "ShopCartPlugin", + { + "glossary":{ + "render_type":"summary" + }, + "pk":14511 + }, + [] + ], + [ + "PaymentMethodFormPlugin", + { + "glossary":{ + "render_type":"form" + }, + "pk":14506 + }, + [] + ], + [ + "ShippingMethodFormPlugin", + { + "glossary":{ + "render_type":"form" + }, + "pk":14507 + }, + [] + ], + [ + "ExtraAnnotationFormPlugin", + { + "glossary":{ + "render_type":"form" + }, + "pk":14508 + }, + [] + ], + [ + "RequiredFormFieldsPlugin", + { + "glossary":{}, + "pk":14509 + }, + [] + ], + [ + "ProcessNextStepPlugin", + { + "glossary":{ + "icon_align":"icon-right", + "symbol":"right-open", + "button_size":"", + "quick_float":"pull-right", + "button_options":[], + "icon_font":"4", + "link_content":"Next", + "button_type":"btn-success", + "hide_plugin":"" + }, + "pk":14510 + }, + [] + ] + ] + ], + [ + "ProcessStepPlugin", + { + "glossary":{ + "hide_plugin":"", + "step_title":"Summary" + }, + "pk":14513 + }, + [ + [ + "HeadingPlugin", + { + "glossary":{ + "content":"Summary of your Order", + "element_id":"", + "tag_type":"h3", + "hide_plugin":"", + "extra_inline_styles:Margins":{ + "margin-right":"", + "margin-top":"", + "margin-left":"", + "margin-bottom":"" + } + }, + "pk":14518 + }, + [] + ], + [ + "ShopCartPlugin", + { + "glossary":{ + "render_type":"static" + }, + "pk":14514 + }, + [] + ], + [ + "SegmentPlugin", + { + "glossary":{ + "open_tag":"if", + "condition":"customer.is_registered" + }, + "pk":14519 + }, + [ + [ + "CustomerFormPlugin", + { + "glossary":{ + "render_type":"summary" + }, + "pk":14520 + }, + [] + ] + ] + ], + [ + "SegmentPlugin", + { + "glossary":{ + "open_tag":"else", + "condition":"" + }, + "pk":14521 + }, + [ + [ + "GuestFormPlugin", + { + "glossary":{ + "render_type":"summary" + }, + "pk":14522 + }, + [] + ] + ] + ], + [ + "PaymentMethodFormPlugin", + { + "glossary":{ + "render_type":"summary" + }, + "pk":14515 + }, + [] + ], + [ + "ShippingMethodFormPlugin", + { + "glossary":{ + "render_type":"summary" + }, + "pk":14516 + }, + [] + ], + [ + "ExtraAnnotationFormPlugin", + { + "glossary":{ + "render_type":"summary" + }, + "pk":14517 + }, + [] + ], + [ + "AcceptConditionPlugin", + { + "body":"

I have read the and agree with them.

", + "pk":14525 + }, + [ + [ + "TextLinkPlugin", + { + "glossary":{ + "link_content":"terms and conditions", + "link":{ + "pk":15, + "model":"cms.Page", + "type":"cmspage", + "section":"" + }, + "target":"", + "title":"" + }, + "pk":14526 + }, + [] + ] + ] + ], + [ + "RequiredFormFieldsPlugin", + { + "glossary":{}, + "pk":14523 + }, + [] + ], + [ + "ShopProceedButton", + { + "glossary":{ + "icon_align":"icon-right", + "symbol":"right-hand", + "button_size":"btn-lg", + "quick_float":"", + "button_options":[], + "icon_font":"4", + "link_content":"Purchase Now", + "link":{ + "type":"PURCHASE_NOW" + }, + "button_type":"btn-success", + "hide_plugin":"" + }, + "pk":14524 + }, + [] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ], + [ + "SegmentPlugin", + { + "glossary":{ + "open_tag":"else", + "condition":"" + }, + "pk":14527 + }, + [ + [ + "BootstrapRowPlugin", + { + "glossary":{ + "extra_inline_styles:Paddings":{ + "padding-right":"", + "padding-left":"" + }, + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"20px" + } + }, + "pk":14528 + }, + [ + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "sm-responsive-utils":"", + "xs-responsive-utils":"", + "lg-column-offset":"", + "sm-column-width":"col-sm-4", + "md-responsive-utils":"", + "xs-column-offset":"", + "md-column-offset":"", + "sm-column-ordering":"", + "sm-column-offset":"", + "lg-column-ordering":"", + "lg-column-width":"", + "xs-column-ordering":"", + "xs-column-width":"col-xs-12", + "lg-responsive-utils":"", + "container_max_widths":{ + "xs":720.0, + "lg":360.0, + "sm":220.0, + "md":293.33 + }, + "md-column-width":"", + "md-column-ordering":"" + }, + "pk":14529 + }, + [ + [ + "ShopAuthenticationPlugin", + { + "glossary":{ + "form_type":"login-reset", + "link":{ + "type":"RELOAD_PAGE" + } + }, + "pk":14530 + }, + [] + ] + ] + ], + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "sm-responsive-utils":"", + "xs-responsive-utils":"", + "md-column-offset":"", + "sm-column-width":"col-sm-4", + "md-responsive-utils":"", + "xs-column-offset":"", + "sm-column-offset":"", + "sm-column-ordering":"", + "md-column-ordering":"", + "lg-column-ordering":"", + "lg-column-offset":"", + "md-column-width":"", + "xs-column-width":"col-xs-12", + "lg-responsive-utils":"", + "container_max_widths":{ + "xs":720.0, + "lg":360.0, + "sm":220.0, + "md":293.33 + }, + "lg-column-width":"", + "xs-column-ordering":"" + }, + "pk":14531 + }, + [ + [ + "ShopAuthenticationPlugin", + { + "glossary":{ + "form_type":"register-user", + "link":{ + "type":"RELOAD_PAGE" + } + }, + "pk":14532 + }, + [] + ] + ] + ], + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "sm-responsive-utils":"", + "xs-responsive-utils":"", + "md-column-offset":"", + "sm-column-width":"col-sm-4", + "md-responsive-utils":"", + "xs-column-offset":"", + "sm-column-offset":"", + "sm-column-ordering":"", + "md-column-ordering":"", + "lg-column-ordering":"", + "lg-column-offset":"", + "md-column-width":"", + "xs-column-width":"col-xs-12", + "lg-responsive-utils":"", + "container_max_widths":{ + "xs":720.0, + "lg":360.0, + "sm":220.0, + "md":293.33 + }, + "lg-column-width":"", + "xs-column-ordering":"" + }, + "pk":14533 + }, + [ + [ + "ShopAuthenticationPlugin", + { + "glossary":{ + "form_type":"continue-as-guest", + "link":{ + "type":"RELOAD_PAGE" + } + }, + "pk":14534 + }, + [] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] +} diff --git a/weirdlittleempire/static/weirdlittleempire/strides/footer.json b/weirdlittleempire/static/weirdlittleempire/strides/footer.json new file mode 100644 index 0000000..5783db2 --- /dev/null +++ b/weirdlittleempire/static/weirdlittleempire/strides/footer.json @@ -0,0 +1,317 @@ +{ + "plugins":[ + [ + "BootstrapContainerPlugin", + { + "glossary":{ + "media_queries":{ + "xs":[ + "(max-width: 768px)" + ], + "lg":[ + "(min-width: 1200px)" + ], + "sm":[ + "(min-width: 768px)", + "(max-width: 992px)" + ], + "md":[ + "(min-width: 992px)", + "(max-width: 1200px)" + ] + }, + "container_max_widths":{ + "xs":750, + "lg":1170, + "sm":750, + "md":970 + }, + "hide_plugin":"", + "fluid":"", + "breakpoints":[ + "xs", + "sm", + "md", + "lg" + ] + }, + "pk":9086 + }, + [ + [ + "BootstrapRowPlugin", + { + "glossary":{ + "extra_css_classes":[], + "hide_plugin":"", + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"" + } + }, + "pk":9087 + }, + [ + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "container_max_widths":{ + "xs":157.5, + "lg":262.5, + "sm":157.5, + "md":212.5 + }, + "xs-column-width":"col-xs-3" + }, + "pk":9088 + }, + [ + [ + "HeadingPlugin", + { + "glossary":{ + "content":"ABOUT US", + "element_id":"", + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"", + "margin-left":"", + "margin-right":"" + }, + "hide_plugin":"", + "tag_type":"h4" + }, + "pk":9089 + }, + [] + ], + [ + "BootstrapSecondaryMenuPlugin", + { + "glossary":{ + "limit":"3", + "page_id":"shop-about", + "hide_plugin":"", + "render_template":"cascade/bootstrap3/secmenu-unstyled-list.html", + "offset":"0" + }, + "pk":9090 + }, + [] + ] + ] + ], + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "container_max_widths":{ + "xs":157.5, + "lg":262.5, + "sm":157.5, + "md":212.5 + }, + "xs-column-width":"col-xs-3" + }, + "pk":9091 + }, + [ + [ + "HeadingPlugin", + { + "glossary":{ + "content":"HELP & CONTACT", + "element_id":"", + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"", + "margin-left":"", + "margin-right":"" + }, + "hide_plugin":"", + "tag_type":"h4" + }, + "pk":9092 + }, + [] + ], + [ + "BootstrapSecondaryMenuPlugin", + { + "glossary":{ + "limit":"100", + "page_id":"shop-contact", + "hide_plugin":"", + "render_template":"cascade/bootstrap3/secmenu-unstyled-list.html", + "offset":"0" + }, + "pk":9093 + }, + [] + ] + ] + ], + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "container_max_widths":{ + "xs":157.5, + "lg":262.5, + "sm":157.5, + "md":212.5 + }, + "xs-column-width":"col-xs-3" + }, + "pk":9094 + }, + [ + [ + "HeadingPlugin", + { + "glossary":{ + "content":"MORE FROM US", + "element_id":"", + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"", + "margin-left":"", + "margin-right":"" + }, + "hide_plugin":"", + "tag_type":"h4" + }, + "pk":9095 + }, + [] + ], + [ + "BootstrapSecondaryMenuPlugin", + { + "glossary":{ + "limit":"3", + "page_id":"shop-more", + "hide_plugin":"", + "render_template":"cascade/bootstrap3/secmenu-unstyled-list.html", + "offset":"0" + }, + "pk":9096 + }, + [] + ] + ] + ], + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "container_max_widths":{ + "xs":157.5, + "lg":262.5, + "sm":157.5, + "md":212.5 + }, + "xs-column-width":"col-xs-3" + }, + "pk":9097 + }, + [ + [ + "SegmentPlugin", + { + "glossary":{ + "open_tag":"if", + "condition":"user.is_anonymous" + }, + "pk":9098 + }, + [ + [ + "HeadingPlugin", + { + "glossary":{ + "content":"Join Us", + "element_id":"", + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"", + "margin-left":"", + "margin-right":"" + }, + "hide_plugin":"", + "tag_type":"h4" + }, + "pk":9099 + }, + [] + ], + [ + "BootstrapSecondaryMenuPlugin", + { + "glossary":{ + "page_id":"shop-membership", + "limit":"100", + "hide_plugin":"", + "render_template":"cascade/bootstrap3/secmenu-unstyled-list.html", + "offset":"0" + }, + "pk":9100 + }, + [] + ] + ] + ], + [ + "SegmentPlugin", + { + "glossary":{ + "open_tag":"else", + "condition":"" + }, + "pk":9101 + }, + [ + [ + "HeadingPlugin", + { + "glossary":{ + "content":"YOUR ACCOUNT", + "element_id":"", + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"", + "margin-left":"", + "margin-right":"" + }, + "hide_plugin":"", + "tag_type":"h4" + }, + "pk":9102 + }, + [] + ], + [ + "BootstrapSecondaryMenuPlugin", + { + "glossary":{ + "page_id":"shop-personal", + "limit":"3", + "hide_plugin":"", + "render_template":"cascade/bootstrap3/secmenu-unstyled-list.html", + "offset":"0" + }, + "pk":9103 + }, + [] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] +} diff --git a/weirdlittleempire/static/weirdlittleempire/strides/home.json b/weirdlittleempire/static/weirdlittleempire/strides/home.json new file mode 100644 index 0000000..b5b8221 --- /dev/null +++ b/weirdlittleempire/static/weirdlittleempire/strides/home.json @@ -0,0 +1,859 @@ +{ + "plugins":[ + [ + "BootstrapJumbotronPlugin", + { + "glossary":{ + "background_width_height":{ + "width":"", + "height":"" + }, + "background_vertical_position":"center", + "media_queries":{ + "xs":[ + "(max-width: 768px)" + ], + "lg":[ + "(min-width: 1200px)" + ], + "sm":[ + "(min-width: 768px)", + "(max-width: 992px)" + ], + "md":[ + "(min-width: 992px)", + "(max-width: 1200px)" + ] + }, + "background_attachment":"fixed", + "image":{ + "pk":184, + "model":"filer.Image" + }, + "background_repeat":"no-repeat", + "hide_plugin":"", + "fluid":true, + "container_max_heights":{ + "xs":"100%", + "md":"100%", + "sm":"100%", + "lg":"100%" + }, + "extra_inline_styles:Paddings":{ + "padding-top":"500px", + "padding-bottom":"" + }, + "background_size":"cover", + "resize_options":[ + "crop", + "subject_location", + "high_resolution" + ], + "container_max_widths":{ + "xs":768, + "lg":1980, + "sm":992, + "md":1200 + }, + "breakpoints":[ + "xs", + "sm", + "md", + "lg" + ], + "background_color":[ + "", + "#12308b" + ], + "background_horizontal_position":"center" + }, + "pk":15056 + }, + [] + ], + [ + "BootstrapContainerPlugin", + { + "glossary":{ + "media_queries":{ + "xs":[ + "(max-width: 768px)" + ], + "lg":[ + "(min-width: 1200px)" + ], + "sm":[ + "(min-width: 768px)", + "(max-width: 992px)" + ], + "md":[ + "(min-width: 992px)", + "(max-width: 1200px)" + ] + }, + "container_max_widths":{ + "xs":750, + "lg":1170, + "sm":750, + "md":970 + }, + "fluid":"", + "breakpoints":[ + "xs", + "sm", + "md", + "lg" + ] + }, + "pk":15057 + }, + [ + [ + "BootstrapRowPlugin", + { + "glossary":{ + "extra_css_classes":[], + "hide_plugin":"", + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"" + } + }, + "pk":15058 + }, + [ + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "container_max_widths":{ + "xs":720.0, + "lg":1140.0, + "sm":720.0, + "md":940.0 + }, + "xs-column-width":"col-xs-12" + }, + "pk":15059 + }, + [ + [ + "CarouselPlugin", + { + "glossary":{ + "resize_options":[ + "upscale", + "crop", + "subject_location", + "high_resolution" + ], + "container_max_heights":{ + "xs":"100px", + "md":"200px", + "sm":"150px", + "lg":"250px" + }, + "interval":"5", + "options":[ + "slide", + "pause", + "wrap" + ] + }, + "pk":15060 + }, + [ + [ + "CarouselSlidePlugin", + { + "glossary":{ + "resize_options":[ + "upscale", + "crop", + "subject_location", + "high_resolution" + ], + "image":{ + "pk":170, + "model":"filer.Image" + }, + "image_title":"", + "alt_tag":"" + }, + "pk":15061 + }, + [ + [ + "TextPlugin", + { + "body":"

Django under the Hood

\n\n

Conference ending

", + "pk":15062 + }, + [] + ] + ] + ], + [ + "CarouselSlidePlugin", + { + "glossary":{ + "resize_options":[ + "upscale", + "crop", + "subject_location", + "high_resolution" + ], + "image":{ + "pk":171, + "model":"filer.Image" + }, + "image_title":"", + "alt_tag":"" + }, + "pk":15063 + }, + [ + [ + "TextPlugin", + { + "body":"

Social Event

\n\n

at , Amsterdam

", + "pk":15064 + }, + [ + [ + "TextLinkPlugin", + { + "glossary":{ + "link_content":"Pllek", + "link":{ + "url":"http://www.pllek.nl/", + "type":"exturl" + }, + "target":"", + "title":"" + }, + "pk":15065 + }, + [] + ] + ] + ] + ] + ], + [ + "CarouselSlidePlugin", + { + "glossary":{ + "resize_options":[ + "upscale", + "crop", + "subject_location", + "high_resolution" + ], + "image":{ + "pk":172, + "model":"filer.Image" + }, + "image_title":"", + "alt_tag":"" + }, + "pk":15066 + }, + [] + ] + ] + ], + [ + "ShopProductGallery", + { + "glossary":{ + "hide_plugin":"" + }, + "pk":15067, + "inlines":[ + { + "product":{ + "pk":50 + } + }, + { + "product":{ + "pk":25 + } + }, + { + "product":{ + "pk":48 + } + }, + { + "product":{ + "pk":22 + } + }, + { + "product":{ + "pk":54 + } + }, + { + "product":{ + "pk":51 + } + }, + { + "product":{ + "pk":49 + } + } + ] + }, + [] + ] + ] + ] + ] + ], + [ + "BootstrapRowPlugin", + { + "glossary":{ + "extra_css_classes":[], + "hide_plugin":"", + "extra_inline_styles:Margins":{ + "margin-top":"10px", + "margin-bottom":"20px" + } + }, + "pk":15068 + }, + [ + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "container_max_widths":{ + "xs":220.0, + "lg":360.0, + "sm":220.0, + "md":293.33 + }, + "xs-column-width":"col-xs-4" + }, + "pk":15069 + }, + [ + [ + "FramedIconPlugin", + { + "glossary":{ + "font_size":"10em", + "color":"#470a31", + "background_color":[ + "", + "#c8ffcd" + ], + "symbol":"heart-empty-2", + "hide_plugin":"", + "text_align":"text-center", + "icon_font":"4", + "border_radius":"50%", + "border":[ + "3px", + "dotted", + "#000000" + ] + }, + "pk":15070 + }, + [] + ] + ] + ], + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "container_max_widths":{ + "xs":220.0, + "lg":360.0, + "sm":220.0, + "md":293.33 + }, + "xs-column-width":"col-xs-4" + }, + "pk":15071 + }, + [ + [ + "FramedIconPlugin", + { + "glossary":{ + "font_size":"10em", + "color":"#470a31", + "background_color":[ + "", + "#c8ffcd" + ], + "symbol":"linux", + "hide_plugin":"", + "text_align":"text-center", + "icon_font":"4", + "border_radius":"50%", + "border":[ + "3px", + "solid", + "#000000" + ] + }, + "pk":15072, + "shared_glossary":"HeadIcon" + }, + [] + ] + ] + ], + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "container_max_widths":{ + "xs":220.0, + "lg":360.0, + "sm":220.0, + "md":293.33 + }, + "xs-column-width":"col-xs-4" + }, + "pk":15073 + }, + [ + [ + "FramedIconPlugin", + { + "glossary":{ + "font_size":"10em", + "color":"#470a31", + "background_color":[ + "", + "#c8ffcd" + ], + "symbol":"windows", + "hide_plugin":"", + "text_align":"text-center", + "icon_font":"4", + "border_radius":"50%", + "border":[ + "3px", + "solid", + "#000000" + ] + }, + "pk":15074, + "shared_glossary":"HeadIcon" + }, + [] + ] + ] + ] + ] + ], + [ + "BootstrapRowPlugin", + { + "glossary":{ + "extra_css_classes":[], + "hide_plugin":"", + "extra_inline_styles:Margins":{ + "margin-top":"", + "margin-bottom":"30px" + } + }, + "pk":15075 + }, + [ + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "sm-responsive-utils":"", + "xs-responsive-utils":"", + "md-column-offset":"", + "sm-column-width":"col-sm-6", + "md-responsive-utils":"", + "xs-column-offset":"", + "sm-column-offset":"", + "sm-column-ordering":"", + "md-column-ordering":"", + "lg-column-ordering":"", + "lg-column-offset":"", + "lg-column-width":"", + "xs-column-width":"col-xs-12", + "lg-responsive-utils":"", + "container_max_widths":{ + "xs":720.0, + "lg":555.0, + "sm":345.0, + "md":455.0 + }, + "md-column-width":"", + "xs-column-ordering":"" + }, + "pk":15076 + }, + [ + [ + "BootstrapPanelPlugin", + { + "glossary":{ + "heading_size":"", + "panel_type":"panel-warning", + "heading":"Panel Heading", + "hide_plugin":"", + "footer":"Panel Footer" + }, + "pk":15077 + }, + [ + [ + "LeafletPlugin", + { + "glossary":{ + "hide_plugin":"", + "map_position":{ + "lat":47.944636605532914, + "lng":12.570934295654299, + "zoom":12 + }, + "render_template":"cascade/plugins/googlemap.html", + "map_height":"400px", + "map_width":"100%" + }, + "pk":15078, + "inlines":[ + { + "position":{ + "lat":47.92554522341879, + "lng":12.618141174316406 + }, + "popup_text":null, + "title":"Marker", + "marker_width":"", + "marker_anchor":{ + "top":"", + "left":"" + } + } + ] + }, + [] + ] + ] + ] + ] + ], + [ + "BootstrapColumnPlugin", + { + "glossary":{ + "sm-responsive-utils":"", + "xs-responsive-utils":"", + "md-column-offset":"", + "sm-column-width":"col-sm-6", + "md-responsive-utils":"", + "xs-column-offset":"", + "sm-column-offset":"", + "sm-column-ordering":"", + "md-column-ordering":"", + "lg-column-ordering":"", + "lg-column-offset":"", + "md-column-width":"", + "xs-column-width":"col-xs-12", + "lg-responsive-utils":"", + "container_max_widths":{ + "xs":720.0, + "lg":555.0, + "sm":345.0, + "md":455.0 + }, + "lg-column-width":"", + "xs-column-ordering":"" + }, + "pk":15079 + }, + [ + [ + "BootstrapAccordionPlugin", + { + "glossary":{ + "hide_plugin":"", + "close_others":"on", + "first_is_open":"on" + }, + "pk":15080 + }, + [ + [ + "BootstrapAccordionPanelPlugin", + { + "glossary":{ + "heading_size":"", + "panel_type":"panel-success", + "panel_title":"First" + }, + "pk":15081 + }, + [ + [ + "TextPlugin", + { + "body":"

Nullam id dolor id nibh ultricies vehicula ut id elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit sit amet non magna.

", + "pk":15082 + }, + [ + [ + "TextLinkPlugin", + { + "glossary":{ + "link_content":"Donec", + "link":{ + "pk":25, + "model":"cms.Page", + "type":"cmspage", + "section":"" + }, + "target":"", + "title":"" + }, + "pk":15083 + }, + [] + ] + ] + ] + ] + ], + [ + "BootstrapAccordionPanelPlugin", + { + "glossary":{ + "heading_size":"", + "panel_type":"panel-success", + "panel_title":"Second" + }, + "pk":15084 + }, + [ + [ + "BootstrapImagePlugin", + { + "glossary":{ + "image_width_responsive":"", + "target":"", + "title":"", + "image":{ + "pk":1, + "model":"filer.Image" + }, + "alt_tag":"", + "image_width_fixed":"", + "image_height":"", + "link":{ + "type":"none" + }, + "resize_options":[ + "upscale", + "crop", + "subject_location", + "high_resolution" + ], + "image_title":"Django Pony", + "image_shapes":[ + "img-responsive" + ] + }, + "pk":15085 + }, + [] + ] + ] + ] + ] + ], + [ + "BootstrapTabSetPlugin", + { + "glossary":{ + "justified":"on" + }, + "pk":15086 + }, + [ + [ + "BootstrapTabPanePlugin", + { + "glossary":{ + "tab_title":"Left" + }, + "pk":15087 + }, + [ + [ + "TextPlugin", + { + "body":"

Vestibulum id ligula porta felis euismod semper

\n\n

\u00a0Vestibulum \u00a0id ligula porta felis euismod semper. id dolor id nibh ultricies vehicula ut id elit. mattis consectetur purus sit amet fermentum. sed odio dui. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.

", + "pk":15088 + }, + [ + [ + "TextLinkPlugin", + { + "glossary":{ + "link_content":"Nullam", + "link":{ + "pk":56, + "model":"myshop.Product", + "type":"product" + }, + "target":"", + "title":"" + }, + "pk":15089 + }, + [] + ], + [ + "TextLinkPlugin", + { + "glossary":{ + "link_content":"Cras", + "link":{ + "pk":55, + "model":"myshop.Product", + "type":"product" + }, + "target":"", + "title":"" + }, + "pk":15090 + }, + [] + ], + [ + "TextIconPlugin", + { + "glossary":{ + "icon_font":"4", + "symbol":"retweet" + }, + "pk":15091 + }, + [] + ], + [ + "TextIconPlugin", + { + "glossary":{ + "icon_font":"4", + "symbol":"camera-alt" + }, + "pk":15092 + }, + [] + ], + [ + "TextLinkPlugin", + { + "glossary":{ + "link_content":"Donec", + "link":{ + "pk":50, + "model":"myshop.Product", + "type":"product" + }, + "target":"", + "title":"" + }, + "pk":15093 + }, + [] + ] + ] + ], + [ + "BootstrapButtonPlugin", + { + "glossary":{ + "icon_align":"icon-right", + "symbol":"angle-circled-right", + "button_size":"btn-lg", + "quick_float":"", + "button_options":[], + "icon_font":"4", + "link_content":"Proceed", + "link":{ + "pk":54, + "model":"myshop.Product", + "type":"product" + }, + "button_type":"btn-info", + "hide_plugin":"" + }, + "pk":15094 + }, + [] + ] + ] + ], + [ + "BootstrapTabPanePlugin", + { + "glossary":{ + "tab_title":"Right" + }, + "pk":15095 + }, + [ + [ + "BootstrapSecondaryMenuPlugin", + { + "glossary":{ + "page_id":"shop-order", + "hide_plugin":"", + "render_template":"cascade/bootstrap3/secmenu-list-group.html" + }, + "pk":15096 + }, + [] + ], + [ + "HeadingPlugin", + { + "glossary":{ + "content":"Heading with Anchor", + "element_id":"anchor1", + "tag_type":"h1", + "hide_plugin":"", + "extra_inline_styles:Margins":{ + "margin-right":"", + "margin-top":"10px", + "margin-bottom":"10px", + "margin-left":"" + } + }, + "pk":15097 + }, + [] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] + ] +} diff --git a/weirdlittleempire/templates/400.html b/weirdlittleempire/templates/400.html new file mode 100644 index 0000000..6fa4df9 --- /dev/null +++ b/weirdlittleempire/templates/400.html @@ -0,0 +1 @@ +{% extends "weirdlittleempire/pages/error.html" %} diff --git a/weirdlittleempire/templates/403.html b/weirdlittleempire/templates/403.html new file mode 100644 index 0000000..6fa4df9 --- /dev/null +++ b/weirdlittleempire/templates/403.html @@ -0,0 +1 @@ +{% extends "weirdlittleempire/pages/error.html" %} diff --git a/weirdlittleempire/templates/404.html b/weirdlittleempire/templates/404.html new file mode 100644 index 0000000..6fa4df9 --- /dev/null +++ b/weirdlittleempire/templates/404.html @@ -0,0 +1 @@ +{% extends "weirdlittleempire/pages/error.html" %} diff --git a/weirdlittleempire/templates/weirdlittleempire/cart/editable.html b/weirdlittleempire/templates/weirdlittleempire/cart/editable.html new file mode 100644 index 0000000..d3b3eae --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/cart/editable.html @@ -0,0 +1 @@ +{% extends "shop/cart/editable.html" %} \ No newline at end of file diff --git a/weirdlittleempire/templates/weirdlittleempire/catalog/commodity-add2cart.html b/weirdlittleempire/templates/weirdlittleempire/catalog/commodity-add2cart.html new file mode 100644 index 0000000..e371b28 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/catalog/commodity-add2cart.html @@ -0,0 +1,12 @@ +{% extends "shop/catalog/available-product-add2cart.html" %} +{% load i18n %} + +{% block available-quantity-in-stock %}{# intentionally empty #}{% endblock %} + +{% block change-purchasing-quantity %} +
+
+ {% trans "This item has already been sold" %} +
+
+{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/catalog/commodity-detail.html b/weirdlittleempire/templates/weirdlittleempire/catalog/commodity-detail.html new file mode 100644 index 0000000..dfafd36 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/catalog/commodity-detail.html @@ -0,0 +1,23 @@ +{% extends "weirdlittleempire/pages/default.html" %} +{% load cms_tags sekizai_tags sass_tags %} + +{% block title %}{{ product.product_name }}{% endblock %} + +{% block breadcrumb %}{% with extra_ance=product.product_name %} + {% if product.show_breadcrumb %}{% include "shop/breadcrumb/default.html" %}{% endif %} +{% endwith %}{% endblock %} + +{% block main-content %} + {# the first `render_placeholder` is only required for editing the page #} + {% render_placeholder product.placeholder %}{% render_placeholder product.placeholder as product_details %} + {% if not product_details %} +
+
+
+

{% render_model product "product_name" %}

+

Edit this page, then switch into Structure mode and add plugins to placeholder {{ product.placeholder.slot }} .

+
+
+
+ {% endif %} +{% endblock main-content %} diff --git a/weirdlittleempire/templates/weirdlittleempire/catalog/manufacturer-filter.html b/weirdlittleempire/templates/weirdlittleempire/catalog/manufacturer-filter.html new file mode 100644 index 0000000..c5e9f52 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/catalog/manufacturer-filter.html @@ -0,0 +1,9 @@ +{% load static sekizai_tags %} + +{% addtoblock "js" %}{% endaddtoblock %} +{% add_data "ng-requires" "django.shop.filter" %} + +
+ {{ filter.filter_set.form.as_div }} +
+ diff --git a/weirdlittleempire/templates/weirdlittleempire/catalog/product-detail.html b/weirdlittleempire/templates/weirdlittleempire/catalog/product-detail.html new file mode 100644 index 0000000..ad3ba92 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/catalog/product-detail.html @@ -0,0 +1,23 @@ +{% extends "weirdlittleempire/pages/default.html" %} +{% load cms_tags sekizai_tags sass_tags %} + +{% block title %}{{ product.product_name }}{% endblock %} + +{% block breadcrumb %}{% with extra_ance=product.product_name %} + {% include "shop/breadcrumb/default.html" %} +{% endwith %}{% endblock %} + +{% block main-content %} +
+
+
+

{% render_model product "product_name" %}

+ {# the first `render_placeholder` is only required for editing the page #} + {% render_placeholder product.placeholder %}{% render_placeholder product.placeholder as product_details %} + {% if not product_details %} +

Edit this page, then switch into Structure mode and add plugins to placeholder {{ product.placeholder.slot }} .

+ {% endif %} +
+
+
+{% endblock main-content %} diff --git a/weirdlittleempire/templates/weirdlittleempire/catalog/smartcard-detail.html b/weirdlittleempire/templates/weirdlittleempire/catalog/smartcard-detail.html new file mode 100644 index 0000000..6774833 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/catalog/smartcard-detail.html @@ -0,0 +1,36 @@ +{% extends "weirdlittleempire/catalog/product-detail.html" %} +{% load i18n cms_tags thumbnail %} + +{% block main-content %} +{% thumbnail product.images.first 250x250 crop as thumb %} +
+
+
+

{% render_model product "product_name" %}

+
+ {{ product.product_name }} +
+ {{ product.description|safe }} +
+
+

{% trans "Details" %}

+
    +
  • +
    {% trans "Card Type" %}:
    + {{ product.get_card_type_display }} +
  • +
  • +
    {% trans "Storage capacity" %}:
    + {{ product.storage }} GB +
  • +
  • +
    {% trans "Manufacturer" %}:
    + {{ product.manufacturer }} +
  • +
+ + {% include "shop/catalog/available-product-add2cart.html" with card_css_classes="mb-3" %} +
+
+
+{% endblock main-content %} diff --git a/weirdlittleempire/templates/weirdlittleempire/catalog/smartphone-add2cart.html b/weirdlittleempire/templates/weirdlittleempire/catalog/smartphone-add2cart.html new file mode 100644 index 0000000..4afde27 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/catalog/smartphone-add2cart.html @@ -0,0 +1,18 @@ +{% extends "shop/catalog/available-product-add2cart.html" %} +{% load i18n %} + +{% block add-to-cart-url %}{{ product.get_absolute_url }}/add-smartphone-to-cart{% endblock %} + +{% block available-quantity-in-stock %} +
+ + +
+ {{ block.super }} +{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/catalog/smartphonemodel-detail.html b/weirdlittleempire/templates/weirdlittleempire/catalog/smartphonemodel-detail.html new file mode 100644 index 0000000..397fccd --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/catalog/smartphonemodel-detail.html @@ -0,0 +1,71 @@ +{% extends "weirdlittleempire/catalog/product-detail.html" %} +{% load i18n static cms_tags sekizai_tags sass_tags %} + +{% block main-content %} + +{% addtoblock "css" %}{% endaddtoblock %} + +{% addtoblock "js" %}{% endaddtoblock %} +{% add_data "ng-requires" "bs-plus.scrollpanel" %} + +
+
+
+

{% render_model product "product_name" %}

+ +
    {% for img in product.images.all %} +
  • {{ product.product_name }}
  • + {% endfor %}
+
+
+
+

{% trans "Details" %}

+ {{ product.description|safe }} +
    +
  • +
    {% trans "Manufacturer" %}:
    + {{ product.manufacturer }} +
  • +
  • +
    {% trans "Battery" %}:
    + {{ product.get_battery_type_display }} ({{ product.battery_capacity }} mAh) +
  • +
  • +
    {% trans "RAM Storage" %}:
    + {{ product.ram_storage }} MB +
  • +
  • +
    {% trans "WiFi Connectivity" %}:
    + {{ product.wifi_connectivity }} +
  • +
  • +
    Bluetooth:
    + {{ product.get_bluetooth_display }} +
  • +
  • +
    GPS:
    + +
  • +
  • +
    {% trans "Dimensions" %}:
    + {{ product.width }} mm (w) × {{ product.height }} mm (h) +
  • +
  • +
    {% trans "Weight" %}:
    + {{ product.weight }} g +
  • +
  • +
    {% trans "Screen size" %}:
    + {{ product.screen_size }} ({% trans "inch" %}) +
  • +
+ + + {% include "weirdlittleempire/catalog/smartphone-add2cart.html" with use_modal_dialog=True card_css_classes="mb-3" %} +
+
+
+ +{% include "shop/catalog/bsp-scrollpanel.tmpl.html" %} + +{% endblock main-content %} diff --git a/weirdlittleempire/templates/weirdlittleempire/email/base.html b/weirdlittleempire/templates/weirdlittleempire/email/base.html new file mode 100644 index 0000000..a77a81e --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/email/base.html @@ -0,0 +1,6 @@ +{% extends "shop/email/base.html" %} +{% load post_office %} + +{% block email-logo %} + +{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/email/password-reset-body.html b/weirdlittleempire/templates/weirdlittleempire/email/password-reset-body.html new file mode 100644 index 0000000..c2ed87a --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/email/password-reset-body.html @@ -0,0 +1,6 @@ +{% extends "shop/email/password-reset-body.html" %} +{% load post_office %} + +{% block email-logo %} + +{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/email/register-user-body.html b/weirdlittleempire/templates/weirdlittleempire/email/register-user-body.html new file mode 100644 index 0000000..66a94e6 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/email/register-user-body.html @@ -0,0 +1,6 @@ +{% extends "shop/email/register-user-body.html" %} +{% load post_office %} + +{% block email-logo %} + +{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/pages/base.html b/weirdlittleempire/templates/weirdlittleempire/pages/base.html new file mode 100644 index 0000000..1bc55b9 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/pages/base.html @@ -0,0 +1,67 @@ +{% load static cms_tags sekizai_tags djng_tags i18n %} + + + + {% block title %}django SHOP demo{% endblock %} + + + + + + {% block head %}{% endblock head %} + {% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %} + + +{% addtoblock "js" %}{% endaddtoblock %} +{% addtoblock "js" %}{% endaddtoblock %} +{% addtoblock "js" %}{% endaddtoblock %} +{% addtoblock "js" %}{% endaddtoblock %} + + + {% cms_toolbar %} +
+ {% block header %}{% endblock %} +
+ + {% block toast-messages %}{% include "shop/messages.html" %}{% endblock %} + +
+ {% block breadcrumb %}{% endblock %} + + {% block main-content %} +
+
+
+

Base Template

+

This document does not contain any content yet.

+
+
+
+ {% endblock main-content %} +
+ +
+ {% block footer %}{% endblock footer %} +
+ + {% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %} + + + + + diff --git a/weirdlittleempire/templates/weirdlittleempire/pages/default.html b/weirdlittleempire/templates/weirdlittleempire/pages/default.html new file mode 100644 index 0000000..f326878 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/pages/default.html @@ -0,0 +1,36 @@ +{% extends "weirdlittleempire/pages/base.html" %} +{% load static cms_tags i18n sekizai_tags sass_tags %} + +{% block title %}{% page_attribute "page_title" %}{% endblock %} + +{% block head %} + {{ block.super }} + {% addtoblock "css" %}{% endaddtoblock %} +{% endblock head %} + +{% block header %} + {% include "weirdlittleempire/pages/navbar.html" with navbar_classes="navbar-expand-lg navbar-light bg-light fixed-top" %} +{% endblock header %} + +{% block breadcrumb %} + {% placeholder "Breadcrumb" %} +{% endblock breadcrumb %} + +{% block main-content %}{% placeholder "Main Content" inherit or %} +
+
+
+

Default Template

+

Use this placeholder as a quick way to start editing a new CMS page.
+ All you have to do is to append ?edit to the URL and switch to “Structure” mode.

+
+
+
+{% endplaceholder %}{% endblock main-content %} + +{% block footer %}{% static_placeholder "Static Footer" or %} +
+

Place sticky footer content here.

+
+{% endstatic_placeholder %}{% endblock footer %} + diff --git a/weirdlittleempire/templates/weirdlittleempire/pages/error.html b/weirdlittleempire/templates/weirdlittleempire/pages/error.html new file mode 100644 index 0000000..d2c20eb --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/pages/error.html @@ -0,0 +1,19 @@ +{% extends "weirdlittleempire/pages/default.html" %}%} +{% load i18n cms_tags %} + +{% block breadcrumb %}{% endblock %} + +{% page_url 'shop-login' as login_url %} + +{% block main-content %} +
+
+
+

{{ detail|default:"Forbidden" }}

+ {% if status_code == 403 and login_url %} +

{% blocktrans %}In case you have ordered anything on this site before, please sign in and try again.{% endblocktrans %}

+ {% endif %} +
+
+
+{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/pages/navbar.html b/weirdlittleempire/templates/weirdlittleempire/pages/navbar.html new file mode 100644 index 0000000..ce277d0 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/pages/navbar.html @@ -0,0 +1,49 @@ +{% extends "bootstrap4/includes/ng-nav-navbar.html" %} +{% load static i18n cms_tags menu_tags sekizai_tags sass_tags shop_tags %} +{% spaceless %} + +{% page_url 'shop-watch-list' as shop_watch_list_url %}{% if not shop_watch_list_url %}{% url "shop-watch-list" as shop_watch_list_url %}{% endif %} + +{% block navbar %} +
+ {% block navbar-brand %} +
+ + + +
+ {% endblock %} + + {% block navbar-toggler %}{{ block.super }}{% endblock %} + + +
+ + {% addtoblock "js" %}{% endaddtoblock %} + {% add_data "ng-requires" "ui.bootstrap" %} + + {% addtoblock "js" %}{% endaddtoblock %} + {% addtoblock "js" %}{% endaddtoblock %} + {% add_data "ng-requires" "django.shop.navbar" %} + +{% endblock navbar %} + +{% endspaceless %} diff --git a/weirdlittleempire/templates/weirdlittleempire/pages/test.html b/weirdlittleempire/templates/weirdlittleempire/pages/test.html new file mode 100644 index 0000000..7d98228 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/pages/test.html @@ -0,0 +1,54 @@ +{% load static i18n cascade_tags djng_tags sekizai_tags sass_tags %} + + + + Test page + + + + + + {% block head %}{% endblock head %} + {% render_block "css" postprocessor "shop.sekizai_processors.compress" %} + + +{% addtoblock "css" %}{% endaddtoblock %} + +{% addtoblock "js" %}{% endaddtoblock %} +{% addtoblock "js" %}{% endaddtoblock %} +{% addtoblock "js" %}{% endaddtoblock %} +{% addtoblock "js" %}{% endaddtoblock %} + + +
+ {% include "weirdlittleempire/pages/navbar.html" with navbar_classes="navbar-default navbar-fixed-top" %} +
+ +
+ {% render_cascade "weirdlittleempire/strides/home.json" %} +
+ +
+ {% block footer %}{% endblock footer %} +
+ + {% render_block "js" postprocessor "shop.sekizai_processors.compress" %} + + + + + diff --git a/weirdlittleempire/templates/weirdlittleempire/print/delivery-note.html b/weirdlittleempire/templates/weirdlittleempire/print/delivery-note.html new file mode 100644 index 0000000..6daf22e --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/print/delivery-note.html @@ -0,0 +1,6 @@ +{% extends "shop/print/delivery-note.html" %} +{% load static %} + +{% block header %} + +{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/print/invoice.html b/weirdlittleempire/templates/weirdlittleempire/print/invoice.html new file mode 100644 index 0000000..d07adfd --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/print/invoice.html @@ -0,0 +1,6 @@ +{% extends "shop/print/invoice.html" %} +{% load static %} + +{% block header %} + +{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/products/cart-product-media.html b/weirdlittleempire/templates/weirdlittleempire/products/cart-product-media.html new file mode 100644 index 0000000..1aaa57a --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/cart-product-media.html @@ -0,0 +1,2 @@ +{% extends "shop/products/cart-product-media.html" %} +{% block sample-image %}{% include "shop/products/sample-image.html" %}{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/products/catalog-product-media.html b/weirdlittleempire/templates/weirdlittleempire/products/catalog-product-media.html new file mode 100644 index 0000000..764e009 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/catalog-product-media.html @@ -0,0 +1,4 @@ +{% load thumbnail %} +{% thumbnail product.sample_image 244x244 crop as thumb %} +{% thumbnail product.sample_image 488x488 crop as thumb2 %} + diff --git a/weirdlittleempire/templates/weirdlittleempire/products/dropdown-product-media.html b/weirdlittleempire/templates/weirdlittleempire/products/dropdown-product-media.html new file mode 100644 index 0000000..ceeae78 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/dropdown-product-media.html @@ -0,0 +1,7 @@ +{% extends "shop/products/dropdown-product-media.html" %} +{% load thumbnail %} +{% block sample-image %} + {% thumbnail product.sample_image 50x50 crop as thumb %} + {% thumbnail product.sample_image 100x100 crop as thumb2 %} + +{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/products/email-product-media.html b/weirdlittleempire/templates/weirdlittleempire/products/email-product-media.html new file mode 100644 index 0000000..9cc8f45 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/email-product-media.html @@ -0,0 +1 @@ +{% extends "shop/products/sample-image.path" %} diff --git a/weirdlittleempire/templates/weirdlittleempire/products/order-product-media.html b/weirdlittleempire/templates/weirdlittleempire/products/order-product-media.html new file mode 100644 index 0000000..9cc70b4 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/order-product-media.html @@ -0,0 +1,2 @@ +{% extends "shop/products/order-product-media.html" %} +{% block sample-image %}{% include "shop/products/sample-image.html" %}{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/products/print-product-media.html b/weirdlittleempire/templates/weirdlittleempire/products/print-product-media.html new file mode 100644 index 0000000..7dd6f02 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/print-product-media.html @@ -0,0 +1,2 @@ +{% extends "shop/products/print-product-media.html" %} +{% block print-image %}{% include "shop/products/print-image.html" %}{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/products/search-product-media.html b/weirdlittleempire/templates/weirdlittleempire/products/search-product-media.html new file mode 100644 index 0000000..dec2131 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/search-product-media.html @@ -0,0 +1,2 @@ +{% extends "shop/products/search-product-media.html" %} +{% block sample-image %}{% include "shop/products/sample-image.html" %}{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/products/search-smartcard-media.html b/weirdlittleempire/templates/weirdlittleempire/products/search-smartcard-media.html new file mode 100644 index 0000000..d4046e6 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/search-smartcard-media.html @@ -0,0 +1,5 @@ +{% extends "weirdlittleempire/products/search-product-media.html" %} +{% block media-body %} +

{{ product.product_name }}

+ {{ product.description|truncatewords_html:50 }} +{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/products/search-smartphonemodel-media.html b/weirdlittleempire/templates/weirdlittleempire/products/search-smartphonemodel-media.html new file mode 100644 index 0000000..cabb47c --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/search-smartphonemodel-media.html @@ -0,0 +1,5 @@ +{% extends "weirdlittleempire/products/search-product-media.html" %} +{% block media-body %} +

{{ product.product_name }}

+ {{ product.caption|truncatewords_html:50 }} +{% endblock %} diff --git a/weirdlittleempire/templates/weirdlittleempire/products/watch-product-media.html b/weirdlittleempire/templates/weirdlittleempire/products/watch-product-media.html new file mode 100644 index 0000000..065fc1a --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/products/watch-product-media.html @@ -0,0 +1 @@ +{% extends "weirdlittleempire/products/cart-product-media.html" %} diff --git a/weirdlittleempire/templates/weirdlittleempire/search/indexes/commodity.txt b/weirdlittleempire/templates/weirdlittleempire/search/indexes/commodity.txt new file mode 100644 index 0000000..70ed674 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/search/indexes/commodity.txt @@ -0,0 +1,3 @@ +{% load shop_search_tags %} +{% include "weirdlittleempire/search/indexes/product.txt" %} +{% render_placeholder product.placeholder %} \ No newline at end of file diff --git a/weirdlittleempire/templates/weirdlittleempire/search/indexes/product.txt b/weirdlittleempire/templates/weirdlittleempire/search/indexes/product.txt new file mode 100644 index 0000000..0367a06 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/search/indexes/product.txt @@ -0,0 +1,3 @@ +{{ product.caption }} +{{ product.manufacturer }}{% for page in product.cms_pages.public %} +{{ page.get_title }}{% endfor %} diff --git a/weirdlittleempire/templates/weirdlittleempire/search/indexes/smartcard.txt b/weirdlittleempire/templates/weirdlittleempire/search/indexes/smartcard.txt new file mode 100644 index 0000000..6cc3f4e --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/search/indexes/smartcard.txt @@ -0,0 +1,3 @@ +{% include "weirdlittleempire/search/indexes/product.txt" %} +{{ product.description }} +{{ product.get_card_type_display }} {{ product.storage }}GB diff --git a/weirdlittleempire/templates/weirdlittleempire/search/indexes/smartphonemodel.txt b/weirdlittleempire/templates/weirdlittleempire/search/indexes/smartphonemodel.txt new file mode 100644 index 0000000..8eb2923 --- /dev/null +++ b/weirdlittleempire/templates/weirdlittleempire/search/indexes/smartphonemodel.txt @@ -0,0 +1,4 @@ +{% include "myshop/search/indexes/product.txt" %} +{{ product.description }} +{{ product.operating_system }}{% for variant in product.get_product_variants %} +{{ variant.storage}}GB{% endfor %} diff --git a/weirdlittleempire/urls.py b/weirdlittleempire/urls.py new file mode 100644 index 0000000..0b7a916 --- /dev/null +++ b/weirdlittleempire/urls.py @@ -0,0 +1,34 @@ +from django.conf import settings +from django.conf.urls.static import static +from django.conf.urls import url, include +from django.conf.urls.i18n import i18n_patterns +from django.contrib import admin +from django.contrib.sitemaps.views import sitemap +from django.http import HttpResponse +from cms.sitemaps import CMSSitemap +from weirdlittleempire.sitemap import ProductSitemap + +sitemaps = {'cmspages': CMSSitemap, + 'products': ProductSitemap} + + +def render_robots(request): + permission = 'noindex' in settings.ROBOTS_META_TAGS and 'Disallow' or 'Allow' + return HttpResponse('User-Agent: *\n%s: /\n' % permission, content_type='text/plain') + + +i18n_urls = ( + url(r'^admin/', admin.site.urls), + url(r'^', include('cms.urls')), +) +urlpatterns = [ + url(r'^robots\.txt$', render_robots), + url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='sitemap'), + url(r'^shop/', include('shop.urls')), +] +if settings.USE_I18N: + urlpatterns.extend(i18n_patterns(*i18n_urls)) +else: + urlpatterns.extend(i18n_urls) +urlpatterns.extend( + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)) diff --git a/worker.py b/worker.py new file mode 100755 index 0000000..7db73f2 --- /dev/null +++ b/worker.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +import os +import redis +import schedule +import time + + +if __name__ == '__main__': + from django import setup + from django.conf import settings + from django.core.management import call_command + from django.utils import timezone + + # initialize Django + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'weirdlittleempire.settings') + setup() + + # schedule jobs + schedule.every().minute.do(call_command, 'send_queued_mail') + rebuild_at = timezone.now() + timezone.timedelta(minutes=6) + schedule.every().hour.at(rebuild_at.strftime(':%M')).do(call_command, 'rebuild_index', interactive=False) + schedule.every().sunday.do(call_command, 'shopcustomers', delete_expired=True) + + if hasattr(settings, 'SESSION_REDIS'): + redis_con = dict((key, settings.SESSION_REDIS[key]) for key in ['host', 'port', 'db', 'socket_timeout']) + pool = redis.ConnectionPool(**redis_con) + r = redis.Redis(connection_pool=pool) + pubsub = r.pubsub() + pubsub.subscribe('django-SHOP') + else: + pubsub = type(str('PubSub'), (), {'get_message': lambda s: None})() + + while True: + message = pubsub.get_message() + if message: + if message['data'] == 'send_queued_mail': + call_command('send_queued_mail') + schedule.run_pending() + time.sleep(1) diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..0c4e224 --- /dev/null +++ b/wsgi.py @@ -0,0 +1,2 @@ +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application()