├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE ├── README.md ├── base.sh ├── doc └── img │ ├── colorChange.png │ └── installation.gif ├── install.py ├── message.txt ├── start.sh ├── test └── tesing.sh └── tlp └── django_app ├── Gruntfile.js ├── LICENSE ├── README.md ├── __init__.py ├── app ├── forms.py ├── management │ ├── __init__.py │ └── commands │ │ ├── __init__.py │ │ └── ovveride_templates.py ├── options │ ├── __init__.py │ ├── debug.py │ ├── task.py │ └── tools.py ├── signals.py ├── tasks.py └── urls.py ├── base_user ├── __init__.py ├── admin.py ├── apps.py ├── forms.py ├── migrations │ └── __init__.py ├── models.py ├── tasks.py ├── templatetags │ ├── __init__.py │ └── base_account.py ├── tests.py ├── tools │ ├── __init__.py │ ├── common.py │ ├── decorator.py │ └── logger.py ├── urls.py └── views.py ├── celery.py ├── docker-compose.yml ├── middleware ├── __init__.py └── force_default_middleware.py ├── oscar_apps ├── __init__.py ├── basket │ ├── __init__.py │ ├── admin.py │ ├── app.py │ ├── config.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_auto_20140827_1705.py │ │ ├── 0003_basket_vouchers.py │ │ ├── 0004_auto_20141007_2032.py │ │ ├── 0005_auto_20150604_1450.py │ │ ├── 0006_auto_20160111_1108.py │ │ ├── 0007_slugfield_noop.py │ │ └── __init__.py │ ├── models.py │ └── views.py ├── catalogue │ ├── __init__.py │ ├── admin.py │ ├── app.py │ ├── config.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_auto_20150217_1221.py │ │ ├── 0003_data_migration_slugs.py │ │ ├── 0004_auto_20150217_1710.py │ │ ├── 0005_auto_20150604_1450.py │ │ ├── 0006_auto_20150807_1725.py │ │ ├── 0007_auto_20151207_1440.py │ │ ├── 0008_auto_20160304_1652.py │ │ ├── 0009_slugfield_noop.py │ │ ├── 0010_auto_20170420_0439.py │ │ ├── 0011_auto_20170422_1355.py │ │ ├── 0012_auto_20170609_1902.py │ │ ├── 0013_auto_20180214_1133.py │ │ ├── 0014_product_best_seller.py │ │ └── __init__.py │ ├── models.py │ └── views.py ├── checkout │ ├── __init__.py │ ├── app.py │ ├── config.py │ ├── forms.py │ ├── models.py │ └── views.py ├── customer │ ├── __init__.py │ ├── admin.py │ ├── app.py │ ├── config.py │ ├── forms.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_auto_20150807_1725.py │ │ ├── 0003_update_email_length.py │ │ ├── 0004_email_save.py │ │ └── __init__.py │ ├── models.py │ └── views.py ├── dashboard │ ├── __init__.py │ ├── catalogue │ │ ├── __init__.py │ │ ├── app.py │ │ ├── config.py │ │ ├── forms.py │ │ ├── formsets.py │ │ ├── models.py │ │ └── views.py │ └── pages │ │ ├── __init__.py │ │ ├── app.py │ │ ├── config.py │ │ ├── forms.py │ │ └── views.py └── promotions │ ├── __init__.py │ ├── admin.py │ ├── app.py │ ├── config.py │ ├── migrations │ ├── 0001_initial.py │ ├── 0002_auto_20150604_1450.py │ └── __init__.py │ ├── models.py │ └── views.py ├── oscar_settings.py ├── oscar_urls.py ├── requirements.txt ├── settings.py ├── settings_django2.py ├── urls.py └── urls_django2.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | .idea/ 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at munisisazade@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Pull Request Process 9 | 10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a 11 | build. 12 | 2. Update the README.md with details of changes to the interface, this includes new environment 13 | variables, exposed ports, useful file locations and container parameters. 14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this 15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). 16 | 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you 17 | do not have permission to do that, you may request the second reviewer to merge it for you. 18 | 19 | ## Code of Conduct 20 | 21 | ### Our Pledge 22 | 23 | In the interest of fostering an open and welcoming environment, we as 24 | contributors and maintainers pledge to making participation in our project and 25 | our community a harassment-free experience for everyone, regardless of age, body 26 | size, disability, ethnicity, gender identity and expression, level of experience, 27 | nationality, personal appearance, race, religion, or sexual identity and 28 | orientation. 29 | 30 | ### Our Standards 31 | 32 | Examples of behavior that contributes to creating a positive environment 33 | include: 34 | 35 | * Using welcoming and inclusive language 36 | * Being respectful of differing viewpoints and experiences 37 | * Gracefully accepting constructive criticism 38 | * Focusing on what is best for the community 39 | * Showing empathy towards other community members 40 | 41 | Examples of unacceptable behavior by participants include: 42 | 43 | * The use of sexualized language or imagery and unwelcome sexual attention or 44 | advances 45 | * Trolling, insulting/derogatory comments, and personal or political attacks 46 | * Public or private harassment 47 | * Publishing others' private information, such as a physical or electronic 48 | address, without explicit permission 49 | * Other conduct which could reasonably be considered inappropriate in a 50 | professional setting 51 | 52 | ### Our Responsibilities 53 | 54 | Project maintainers are responsible for clarifying the standards of acceptable 55 | behavior and are expected to take appropriate and fair corrective action in 56 | response to any instances of unacceptable behavior. 57 | 58 | Project maintainers have the right and responsibility to remove, edit, or 59 | reject comments, commits, code, wiki edits, issues, and other contributions 60 | that are not aligned to this Code of Conduct, or to ban temporarily or 61 | permanently any contributor for other behaviors that they deem inappropriate, 62 | threatening, offensive, or harmful. 63 | 64 | ### Scope 65 | 66 | This Code of Conduct applies both within project spaces and in public spaces 67 | when an individual is representing the project or its community. Examples of 68 | representing a project or community include using an official project e-mail 69 | address, posting via an official social media account, or acting as an appointed 70 | representative at an online or offline event. Representation of a project may be 71 | further defined and clarified by project maintainers. 72 | 73 | ### Enforcement 74 | 75 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 76 | reported by contacting the project team at [INSERT EMAIL ADDRESS]. All 77 | complaints will be reviewed and investigated and will result in a response that 78 | is deemed necessary and appropriate to the circumstances. The project team is 79 | obligated to maintain confidentiality with regard to the reporter of an incident. 80 | Further details of specific enforcement policies may be posted separately. 81 | 82 | Project maintainers who do not follow or enforce the Code of Conduct in good 83 | faith may face temporary or permanent repercussions as determined by other 84 | members of the project's leadership. 85 | 86 | ### Attribution 87 | 88 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 89 | available at [https://github.com/munisisazade/create-django-app][version] 90 | 91 | [homepage]: https://github.com/munisisazade/create-django-app 92 | [version]: https://github.com/munisisazade/create-django-app 93 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Add Contributing #1 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Munis Isazade 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # create-django-app # 2 | 3 | [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/munisisazade/create-django-app/master/LICENSE) 4 | [![GitHub issues](https://img.shields.io/github/issues/munisisazade/create-django-app.svg)](https://github.com/munisisazade/create-django-app/issues) 5 | [![GitHub forks](https://img.shields.io/github/forks/munisisazade/create-django-app.svg)](https://github.com/munisisazade/create-django-app/network) 6 | [![GitHub stars](https://img.shields.io/github/stars/munisisazade/create-django-app.svg)](https://github.com/munisisazade/create-django-app/stargazers) 7 | [![Apple Macbook](https://img.shields.io/badge/operation%20system-Macbook%20Pro-brightgreen.svg)](https://www.apple.com/lae/macos/mojave/) 8 | [![Linux Ubuntu](https://img.shields.io/badge/operation%20system-Ubuntu%2016.04+-brightgreen.svg)](https://www.apple.com/lae/macos/mojave/) 9 | ### --- Installation command ### 10 | 11 | First check this bellow command: 12 | One line download script copy paste your terminal 13 | ``` 14 | #! 15 | $ git clone https://github.com/munisisazade/create-django-app.git && cd create-django-app/ && python3 install.py && cd .. && rm -rf create-django-app/ 16 | ``` 17 | 18 | ### --- Set up synced folders ### 19 | Create new Django app with bellow command: 20 | ``` 21 | #! 22 | 23 | $ create-django-app talasemia 24 | ``` 25 | 26 | # Documentations # 27 | 28 | ### First Installation step ### 29 | ![](https://raw.githubusercontent.com/munisisazade/create-django-app/master/doc/img/installation.gif) 30 | 31 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 32 | # Django # 33 | 34 | 35 | ### --- Activate Virtualenviroment Python 3 ### 36 | 37 | Change into the directory, you want create virtual environment: 38 | ``` 39 | #! 40 | 41 | $ source .venv/bin/activate 42 | ``` 43 | 44 | ### --- The development server ### 45 | 46 | Change into the outer mysite directory, if you haven’t already, and run the following commands: 47 | ``` 48 | #! 49 | 50 | $ python manage.py runserver 51 | ``` 52 | 53 | ### --- Creating a project / app ### 54 | 55 | Project: 56 | ``` 57 | #! 58 | 59 | $ django-admin startproject 60 | ``` 61 | To create your **app**, make sure you’re in the same directory as manage.py and type this command: 62 | ``` 63 | #! 64 | 65 | $ python manage.py startapp 66 | ``` 67 | 68 | 69 | 70 | ### --- Superuser ### 71 | 72 | Create superusers using the createsuperuser command: 73 | ``` 74 | #! 75 | 76 | $ python manage.py createsuperuser --username=joe --email=joe@example.com 77 | ``` 78 | 79 | 80 | 81 | ### --- Migrate ### 82 | 83 | By running **makemigrations**, you’re telling Django that you’ve made some changes to your models (in this case, you’ve made new ones) and that you’d like the changes to be stored as a *migration*. 84 | 85 | 86 | ``` 87 | #! 88 | 89 | $ python manage.py makemigrations 90 | ``` 91 | 92 | Now, run **migrate** again to create those model tables in your database: 93 | 94 | 95 | ``` 96 | #! 97 | 98 | $ python manage.py migrate 99 | ``` 100 | 101 | 102 | ### --- Running tests ### 103 | 104 | In the terminal, we can run our test: 105 | ``` 106 | #! 107 | $ python manage.py test 108 | ``` 109 | 110 | 111 | 112 | 113 | 114 | 115 | ### --- Shell ### 116 | 117 | To invoke the Python shell, use this command: 118 | ``` 119 | #! 120 | $ python manage.py shell 121 | ``` 122 | 123 | 124 | ### --- Install dependencies ### 125 | 126 | Installing required dependencies on virtual environment: 127 | ``` 128 | #! 129 | $ pip freeze > requirements.txt 130 | $ pip install -r requirements.txt 131 | ``` 132 | 133 | 134 | 135 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 136 | 137 | ### --- Credits & Helpers ### 138 | 1. Extend your RAM by adding a swap file - http://stackoverflow.com/a/18335151/968751 139 | 1. Make ffmpeg executable everywhere - http://askubuntu.com/a/613799 140 | 1. FFMpeg permission denied error - http://askubuntu.com/a/478019 141 | 1. One liner ffmpeg (or other) to get only resolution? - http://askubuntu.com/a/577431 / http://stackoverflow.com/a/29585066 (json) 142 | 1. Revert to a commit by a SHA hash in Git? - http://stackoverflow.com/a/1895095 143 | 144 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 145 | 146 | ### --- Used modules & Apps ### 147 | 1. Media server: [ngnix RMTP](https://github.com/arut/nginx-rtmp-module) 148 | 1. Video edit: [ffmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) 149 | -------------------------------------------------------------------------------- /doc/img/colorChange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/doc/img/colorChange.png -------------------------------------------------------------------------------- /doc/img/installation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/doc/img/installation.gif -------------------------------------------------------------------------------- /install.py: -------------------------------------------------------------------------------- 1 | # Author Munis Isazade 2 | import subprocess # import subprecess for Run to Linux bash script 3 | import sys 4 | 5 | if len(sys.argv) > 1: 6 | if sys.argv[1] == "update": 7 | subprocess.call(['chmod +x start.sh && ./start.sh update'], shell=True) # update module 8 | else: 9 | print("Started to install Command ...") # Print start 10 | subprocess.call(['chmod +x start.sh && ./start.sh'],shell=True) # call sh shell script for excecute script 11 | 12 | -------------------------------------------------------------------------------- /message.txt: -------------------------------------------------------------------------------- 1 | #432329 new version relase 2.1.1 2 | * add new operation system Darwin 3 | * support all mac operation systems 4 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author Munis Isazade 3 | COMMAND_NAME=create-django-app 4 | if [[ "$OSTYPE" == "darwin"* ]]; then 5 | LOCAL_COMMAND_DIRECTORY=/usr/local/bin 6 | TLP_DIRECTORY=/usr/local/share 7 | else 8 | LOCAL_COMMAND_DIRECTORY=~/.local/bin 9 | TLP_DIRECTORY=~/.local/share 10 | fi 11 | GIR_REPO_URL=https://github.com/munisisazade/create-django-app.git 12 | #usage: ChangeColor $COLOR text/background 13 | function ChangeColor() 14 | { 15 | TYPE="" 16 | case "$2" in 17 | "text") TYPE="setaf" 18 | ;; 19 | "back") TYPE="setab" 20 | ;; 21 | *) TYPE="setaf" 22 | esac 23 | 24 | 25 | 26 | case "$1" in 27 | "red") tput "$TYPE" 1 28 | ;; 29 | "orange") tput "$TYPE" 3 30 | ;; 31 | "blue") tput "$TYPE" 4 32 | ;; 33 | "green") tput "$TYPE" 2 34 | ;; 35 | "black") tput "$TYPE" 0 36 | ;; 37 | "white") tput "$TYPE" 7 38 | ;; 39 | "magenta") tput "$TYPE" 5 40 | ;; 41 | "cyan") tput "$TYPE" 7 42 | ;; 43 | *) tput "$TYPE" 0 44 | esac 45 | } 46 | 47 | if [[ $1 ]]; then 48 | cp base.sh $COMMAND_NAME 49 | chmod +x $COMMAND_NAME 50 | rm -rf $TLP_DIRECTORY/django_app/ 51 | rm -rf $LOCAL_COMMAND_DIRECTORY/create-django-app 52 | if [ -d $LOCAL_COMMAND_DIRECTORY ]; then 53 | mv $COMMAND_NAME $LOCAL_COMMAND_DIRECTORY 54 | if [ -d $TLP_DIRECTORY ]; then 55 | cp -r tlp/django_app $TLP_DIRECTORY/ 56 | else 57 | cd ~/.local/ 58 | mkdir share 59 | cp -r tlp/django_app $TLP_DIRECTORY/ 60 | fi 61 | else 62 | cd ~ 63 | mkdir .local 64 | cd .local/ 65 | mkdir bin/ 66 | mv $COMMAND_NAME $LOCAL_COMMAND_DIRECTORY 67 | mkdir share 68 | cp -r tlp/django_app $TLP_DIRECTORY/ 69 | sudo echo "# set PATH so it includes user's private bin directories" >> ~/.profile 70 | sudo echo "PATH=\"\$HOME/bin:\$HOME/.local/bin:\$PATH\"" >> ~/.profile 71 | fi 72 | echo -e "\n" 73 | echo -e " Successfuly Updated $(ChangeColor green text)$COMMAND_NAME$(ChangeColor white text) " 74 | echo -e "\n" 75 | echo -e "Please specify the project directory:" 76 | echo -e "$(ChangeColor blue text) create-django-app $(ChangeColor green text)$(ChangeColor white text)" 77 | echo -e "\n" 78 | echo -e "For example:" 79 | echo -e "$(ChangeColor blue text) create-django-app $(ChangeColor green text)my-django-app$(ChangeColor white text)" 80 | echo -e "\n" 81 | echo -e "Run $(ChangeColor blue text)create-django-app --help$(ChangeColor white text) to see all options." 82 | else 83 | cp base.sh $COMMAND_NAME 84 | chmod +x $COMMAND_NAME 85 | if [ -d $LOCAL_COMMAND_DIRECTORY ]; then 86 | mv $COMMAND_NAME $LOCAL_COMMAND_DIRECTORY 87 | if [ -d $TLP_DIRECTORY ]; then 88 | cp -r tlp/django_app $TLP_DIRECTORY/ 89 | else 90 | cd ~/.local/ 91 | mkdir share 92 | cp -r tlp/django_app $TLP_DIRECTORY/ 93 | fi 94 | else 95 | cd ~ 96 | mkdir .local 97 | cd .local/ 98 | mkdir bin/ 99 | mv $COMMAND_NAME $LOCAL_COMMAND_DIRECTORY 100 | mkdir share 101 | cp -r tlp/django_app $TLP_DIRECTORY/ 102 | sudo echo "# set PATH so it includes user's private bin directories" >> ~/.profile 103 | sudo echo "PATH=\"\$HOME/bin:\$HOME/.local/bin:\$PATH\"" >> ~/.profile 104 | fi 105 | 106 | mkdir ~/.$COMMAND_NAME 107 | cd ~/.$COMMAND_NAME 108 | git init 109 | git remote add origin $GIR_REPO_URL 110 | git fetch origin 111 | git reset --hard origin/master 112 | git branch --set-upstream-to origin/master 113 | echo -e "$(ChangeColor green text)" 114 | echo -ne '## (0%)\r' 115 | sleep 0.5 116 | echo -ne '#### (10%)\r' 117 | sleep 0.5 118 | echo -ne '###### (20%)\r' 119 | sleep 0.5 120 | echo -ne '######## (30%)\r' 121 | sleep 0.5 122 | echo -ne '########## (40%)\r' 123 | sleep 0.5 124 | echo -ne '############ (50%)\r' 125 | sleep 0.5 126 | echo -ne '############## (60%)\r' 127 | sleep 0.5 128 | echo -ne '################ (70%)\r' 129 | sleep 0.5 130 | echo -ne '################## (80%)\r' 131 | sleep 0.5 132 | echo -ne '#################### (90%)\r' 133 | sleep 0.5 134 | echo -ne '######################(100%)\r' 135 | echo -ne '\n' 136 | echo -e "$(ChangeColor white text)" 137 | 138 | 139 | echo -e "\n" 140 | echo -e " Successfuly installed $(ChangeColor green text)$COMMAND_NAME$(ChangeColor white text) " 141 | echo -e "\n" 142 | echo -e "Please specify the project directory:" 143 | echo -e "$(ChangeColor blue text) create-django-app $(ChangeColor green text)$(ChangeColor white text)" 144 | echo -e "\n" 145 | echo -e "For example:" 146 | echo -e "$(ChangeColor blue text) create-django-app $(ChangeColor green text)my-django-app$(ChangeColor white text)" 147 | echo -e "\n" 148 | echo -e "Run $(ChangeColor blue text)create-django-app --help$(ChangeColor white text) to see all options." 149 | fi 150 | 151 | exit 1 -------------------------------------------------------------------------------- /test/tesing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author Munis Isazade 3 | #COMMAND_NAME=create-django-app 4 | #if [[ "$OSTYPE" == "darwin"* ]]; then 5 | # LOCAL_COMMAND_DIRECTORY=/usr/local/bin/ 6 | # TLP_DIRECTORY=/usr/local/share/ 7 | #else 8 | # LOCAL_COMMAND_DIRECTORY=~/.local/bin/ 9 | # TLP_DIRECTORY=~/.local/share/ 10 | #fi 11 | # 12 | #echo "My local command directory is $LOCAL_COMMAND_DIRECTORY" 13 | #echo "My local share directory is $TLP_DIRECTORY" 14 | # 15 | ##MUNISS="asdasd" 16 | # 17 | #if [[ ! -z "$MUNISS" ]]; then 18 | # echo "Beli yoxdur" 19 | #else 20 | # echo "Var" 21 | #fi 22 | # 23 | TOKEN=$(python -c 'import random, string; result = "".join([random.choice(string.ascii_letters + string.digits) for i in range(16)]); print(result)') 24 | echo $TOKEN 25 | 26 | -------------------------------------------------------------------------------- /tlp/django_app/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | // Configurable paths for the application 4 | var appConfig = { 5 | app: 'dev', 6 | dist: '../../static/#{STATIC_ROOT}', 7 | hlp: { 8 | bowerPath: './bower_components', 9 | bowerJS: [ 10 | 'bootstrap-sass/assets/javascripts/bootstrap.js', 11 | 'jquery/dist/jquery.js', 12 | 'owl.carousel/dist/owl.carousel.js', 13 | 'slick-carousel/slick/slick.js', 14 | 'jquery-ui/jquery-ui.js', 15 | 'jquery.mb.ytplayer/dist/jquery.mb.YTPlayer.js', 16 | 'magnific-popup/dist/jquery.magnific-popup.js' 17 | ], 18 | pathRemove: [ 19 | 'bootstrap-sass/assets/fonts', '/fonts','owl.carousel/', 20 | 'font-awesome/fonts','slick-carousel/slick/fonts' 21 | ], 22 | pathIgnore: [ 23 | '!font-awesome/**/*.css', 24 | '!jcf/**/*.{png,jpg,gif,ico,jpeg,css}', 25 | '!owl.carousel/dist/**/*.css', 26 | '!owl.carousel/docs/**/**/*.css', 27 | '!owl.carousel/docs/**/**/**/*.css', 28 | '!owl.carousel/docs/assets/img/*.{png,jpg,gif,ico,jpeg}', 29 | '!owl.carousel/docs/assets/owlcarousel/assets/*.{png,jpg,gif,ico,jpeg}', 30 | '!owl.carousel/docs_src/assets/img/*.{png,jpg,gif,ico,jpeg}', 31 | '!owl.carousel/src/img/*.{png,jpg,gif,ico,jpeg}', 32 | '!owl.carousel/dist/**/*.{png,jpg,gif,ico,jpeg}', 33 | '!owl.carousel/docs/**/*.{png,jpg,gif,ico,jpeg}', 34 | '!slick-carousel/slick/*.css', 35 | '!jquery-ui/themes/**/*.css', 36 | '!jquery-ui/themes/**/*.{png,jpg,gif,ico,jpeg}', 37 | '!slick-carousel/slick/*.{png,jpg,gif,ico,jpeg}', 38 | '!magnific-popup/dist/*.css' 39 | ] 40 | }, 41 | currentAbsPath: process.cwd(), 42 | }, 43 | // remove unnecessary subdirectories 44 | removePath = function (dest, src) { 45 | var paths = appConfig.hlp.pathRemove; 46 | 47 | paths.map(function(element, index, array) { 48 | if (src.indexOf(element) > -1) { 49 | // The `src` is being renamed; the `dest` remains the same 50 | src = src.replace(element, ''); 51 | } 52 | }); 53 | return dest + src; 54 | }; 55 | 56 | // Project configuration. 57 | grunt.initConfig({ 58 | 59 | pkg: grunt.file.readJSON('package.json'), 60 | 61 | // Project settings 62 | conf: appConfig, 63 | 64 | 65 | // Coffee plugin 66 | coffee: { 67 | compile: { 68 | files: { 69 | 'js/script/coffee.js': ['_coffee/*.coffee', '_coffee/**/*.coffee'] 70 | } 71 | } 72 | }, 73 | 74 | // Compass plugin 75 | compass: { 76 | // Build the minified css 77 | dist: { 78 | options: { 79 | banner: '/*!\n' + 80 | ' * <%= pkg.name %>\n' + 81 | ' * <%= pkg.url %>\n' + 82 | ' * @author <%= pkg.author %>\n' + 83 | ' * @author-url <%= pkg.authorUrl %>\n' + 84 | ' * @version <%= pkg.version %>\n' + 85 | ' */\n', 86 | relativeAssets: true, 87 | sassDir: '_sass', 88 | cssDir: '<%= conf.dist %>/css', 89 | imagesDir: '_assets/', 90 | fontsDir: '<%= conf.dist %>/fonts/', 91 | generatedImagesDir: "<%= conf.dist %>/img/", 92 | httpGeneratedImagesPath: "../img", 93 | environment: 'production', 94 | specify: '_sass/*.min.scss' 95 | } 96 | }, 97 | // Build not minified css 98 | build: { 99 | options : { 100 | // banner: '<%= compass.dist.options.banner %>', 101 | relativeAssets: '<%= compass.dist.options.relativeAssets %>', 102 | sassDir: '<%= compass.dist.options.sassDir %>', 103 | cssDir: '<%= compass.dist.options.cssDir %>', 104 | imagesDir: '<%= compass.dist.options.imagesDir %>', 105 | fontsDir: '<%= compass.dist.options.fontsDir %>', 106 | generatedImagesDir: '<%= compass.dist.options.generatedImagesDir %>', 107 | httpGeneratedImagesPath: '<%= compass.dist.options.httpGeneratedImagesPath %>', 108 | noLineComment: true, 109 | environment: 'development', 110 | specify: '_sass/*.scss' 111 | } 112 | } 113 | }, 114 | 115 | // fonts-face generator 116 | fontface: { 117 | dist: { 118 | options: { 119 | fontDir: 'fonts', 120 | outputFile: '_sass/_quarks/fonts.scss', 121 | template: 122 | '@include font-face("' + 123 | '{{font}}", font-files(' + 124 | '"{{font}}.woff", ' + 125 | '"{{font}}.ttf", ' + 126 | '"{{font}}.svg#{{font}}"), ' + 127 | '"{{font}}.eot");' 128 | } 129 | } 130 | }, 131 | 132 | // Concat plugin 133 | concat: { 134 | compact: { 135 | options: { 136 | separator: ';' 137 | }, 138 | // Uncomment if you want to get compact.js that contains all js files from folder 139 | src: ['!js/libs/**/*.js', '!js/script/!**!/!*.js', 'js/assets/!**/!*.js', 'js/!*.js'], 140 | dest: 'js/built/compact.js' 141 | }, 142 | js: { 143 | src: ['js/script/*.js'], 144 | dest: 'js/app.js' 145 | } 146 | }, 147 | 148 | 149 | // Uglify plugin 150 | uglify: { // Minify files with UglifyJS. 151 | options: { 152 | /*mangle: { 153 | except: ['jQuery'] 154 | },*/ 155 | banner: '/*!\n' + 156 | ' * <%= pkg.name %>\n' + 157 | ' * <%= pkg.url %>\n' + 158 | ' * @author <%= pkg.author %>\n' + 159 | ' * @author-url <%= pkg.authorUrl %>\n' + 160 | ' * @version <%= pkg.version %>\n' + 161 | ' * @updated <%= grunt.template.today("yyyy-mm-dd") %> */\n' 162 | }, 163 | build: { 164 | files: [ 165 | { 166 | expand: true, 167 | cwd: 'js', 168 | src: ['libs/*.js', 'assets/*.js', 'built/*.js', '*.js'], 169 | // src: ['libs/*.js', 'assets/*.js', '!built/*.js', '*.js'], 170 | dest: '<%= conf.dist %>/js/min/', 171 | ext: '.min.js' 172 | } 173 | ] 174 | } 175 | }, 176 | 177 | 178 | // Bower copy plugin 179 | copy: { 180 | bower: { 181 | files: [ 182 | { 183 | expand: true, 184 | cwd: '<%= conf.hlp.bowerPath %>/', 185 | src: ['**/*.css', '<%= conf.hlp.pathIgnore %>'], 186 | dest: '<%= conf.dist %>/css/', 187 | flatten: true, 188 | filter: 'isFile' 189 | }, 190 | { 191 | expand: true, 192 | cwd: '<%= conf.hlp.bowerPath %>/', 193 | src: '**/*.{svg,eot,ttf,woff,woff2,otf}', 194 | dest: '<%= conf.dist %>/fonts/', 195 | //flatten: true, 196 | filter: 'isFile', 197 | rename: removePath 198 | }, 199 | { 200 | expand: true, 201 | cwd: '<%= conf.hlp.bowerPath %>/', 202 | src: ['**/*.{png,jpg,gif,ico,jpeg}', '<%= conf.hlp.pathIgnore %>'], 203 | dest: '<%= conf.dist %>/img/', 204 | //flatten: true, 205 | filter: 'isFile', 206 | rename: removePath 207 | }, 208 | { 209 | expand: true, 210 | cwd: '<%= conf.hlp.bowerPath %>/', 211 | src: '<%= conf.hlp.bowerJS %>', 212 | dest: 'js/assets/', 213 | flatten: true, 214 | filter: 'isFile' 215 | } 216 | ] 217 | }, 218 | js: { 219 | files: [ 220 | { 221 | expand: true, 222 | cwd: 'js/', 223 | src: '**/*.js', 224 | dest: '<%= conf.dist %>/js/', 225 | flatten: true, 226 | filter: 'isFile' 227 | } 228 | ] 229 | }, 230 | fonts: { 231 | files: [ 232 | { 233 | expand: true, 234 | cwd: 'fonts/', 235 | src: '**/*.{svg,eot,ttf,woff,woff2,otf}', 236 | dest: '<%= conf.dist %>/fonts/', 237 | filter: 'isFile' 238 | } 239 | ] 240 | }, 241 | images: { 242 | files: [ 243 | { 244 | expand: true, 245 | cwd: '_assets/images/', 246 | src: '**/*.{svg,jpg,jpeg,png,gif}', 247 | dest: '<%= conf.dist %>/img/', 248 | filter: 'isFile' 249 | } 250 | ] 251 | } 252 | }, 253 | 254 | 255 | // Jshint plugin 256 | jshint: { // Validate files with JSHint. 257 | all: ['Gruntfile.js', 'js/**/*.js', '!js/built/compact.js', '!js/assets/**/*.js'] 258 | }, 259 | 260 | // SVG Sprite 261 | svg_sprite: { 262 | basic: { 263 | // Target basics 264 | // expand: true, 265 | cwd: '_assets/svg', 266 | src: '**/*.svg', 267 | dest: '<%= conf.dist %>', 268 | 269 | // Target options 270 | options: { 271 | mode: { 272 | css: { // Activate the «css» mode 273 | render: { 274 | css: false, // Activate CSS output (with default options) 275 | scss: { 276 | dest: '<%= conf.currentAbsPath %>/_sass/_molecules/svg-sprite.scss', 277 | template: './__lib/templates/svg-sprite.mustache' 278 | } 279 | }, 280 | prefix: ".svg--%s", 281 | dimensions : "--size", 282 | // dest: '', 283 | sprite: "../img/sprite.svg" 284 | } 285 | } 286 | } 287 | } 288 | }, 289 | 290 | 291 | // Assemble template html 292 | assemble: { 293 | options: { 294 | flatten: true, 295 | partials: ['_templates/_includes/**/*.hbs'], 296 | layoutdir: '_templates/_layouts', 297 | layout: 'default.hbs', 298 | staticPath: '..', 299 | helpers: ['./__lib/handlebars-helpers/**/*.js'], 300 | data: ['<%= conf.currentAbsPath %>/__data/**/*.{json,yml}'] 301 | }, 302 | site: { 303 | files: {'../public/': ['_templates/_pages/*.hbs']} 304 | } 305 | }, 306 | 307 | 308 | // Injector (for including js/css files to html dynamically) 309 | injector: { 310 | options: { 311 | addRootSlash: false, 312 | ignorePath: '<%= conf.dist %>' 313 | }, 314 | local_dependencies: { 315 | files: { 316 | '_templates/_includes/head.hbs': [ 317 | '<%= conf.dist %>/js/min/assets/**/jquery.min.js', 318 | '<%= conf.dist %>/js/min/assets/**/*.min.js', 319 | '<%= conf.dist %>/js/min/**/*.min.js', 320 | '!<%= conf.dist %>/js/min/**/compact.min.js', 321 | '<%= conf.dist %>/css/**/*.min.css', 322 | '!<%= conf.dist %>/css/**/bootstrap.min.css' 323 | ] 324 | } 325 | } 326 | }, 327 | 328 | // clean unnecessary files 329 | clean: { 330 | options: { force: true }, 331 | svg_sprite: { 332 | src: [ 333 | "<%= conf.dist %>/img/**/sprite-*.svg" 334 | ] 335 | }, 336 | images: { 337 | src: [ 338 | "<%= conf.dist %>/img/**/*.{png,jpg,jpeg,svg}", 339 | "!<%= conf.dist %>/img/**/sprite-*.svg", 340 | "!<%= conf.dist %>/img/**/pico-*.png" 341 | ] 342 | } 343 | }, 344 | 345 | 346 | // Watch plugin 347 | watch: { 348 | options: { 349 | livereload: true // 350 | }, 351 | 352 | // Watch css 353 | css: { 354 | files: ['_sass/*.scss', '_sass/**/*.scss'], 355 | tasks: ['compass:dist'] 356 | }, 357 | 358 | // Watch js 359 | js: { 360 | files: ['js/**/*.js', 'js/*.js', 'Gruntfile.js' ], 361 | tasks: ['concat:js', 'jshint', 'newer:uglify'] 362 | }, 363 | 364 | // Watch HandleBarScript 365 | hbs: { 366 | files: ['_templates/**/*.hbs', '_templates/*.hbs', '<%= assemble.options.data %>'], 367 | tasks: ['assemble'] 368 | }, 369 | 370 | // Watch coffee 371 | scripts: { 372 | files: ['_coffee/*.coffee'], 373 | tasks: [ 'newer:coffee' ] 374 | }, 375 | 376 | // Watch SVG 377 | svg: { 378 | files: ['<%= svg_sprite.basic.cwd %>/<%= svg_sprite.basic.src %>'], 379 | tasks: ['svg'] 380 | }, 381 | 382 | // Watch images 383 | images: { 384 | files: ['_assets/images/**/*'], 385 | tasks: ['clean:images', 'copy:images'] 386 | } 387 | } 388 | 389 | }); 390 | 391 | 392 | // NPM tasks 393 | grunt.loadNpmTasks('grunt-contrib-coffee'); 394 | grunt.loadNpmTasks('grunt-contrib-compass'); 395 | grunt.loadNpmTasks('grunt-contrib-watch'); 396 | grunt.loadNpmTasks('grunt-contrib-concat'); 397 | grunt.loadNpmTasks('grunt-contrib-jshint'); 398 | grunt.loadNpmTasks('grunt-contrib-uglify'); 399 | grunt.loadNpmTasks('grunt-contrib-copy'); 400 | grunt.loadNpmTasks('grunt-contrib-clean'); 401 | grunt.loadNpmTasks('grunt-newer'); 402 | grunt.loadNpmTasks('grunt-assemble'); 403 | grunt.loadNpmTasks('grunt-injector'); 404 | grunt.loadNpmTasks('grunt-fontface'); 405 | grunt.loadNpmTasks('grunt-svg-sprite'); 406 | 407 | 408 | 409 | // Default tasks on running. 410 | grunt.registerTask('default', ['coffee', 'uglify', 'injector', 'assemble']); 411 | 412 | // Task for build fonts 413 | grunt.registerTask('fonts', ['fontface', 'copy:fonts']); 414 | 415 | // Task for inject to html js/css files 416 | grunt.registerTask('inject', ['injector']); 417 | 418 | // Task for sprite svg file 419 | grunt.registerTask('svg', ['clean:svg_sprite', 'svg_sprite']); 420 | 421 | // Task for build bower components 422 | grunt.registerTask('bower:update', ['copy:bower']); 423 | 424 | // Task for build public version of js 425 | grunt.registerTask('build', ['fontface', 'clean:images', 'copy', 'svg', 'compass', 'concat', 'jshint', 'uglify', 'assemble']); 426 | 427 | }; 428 | 429 | -------------------------------------------------------------------------------- /tlp/django_app/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Munis Isazade 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /tlp/django_app/README.md: -------------------------------------------------------------------------------- 1 | # README # 2 | 3 | # #{PROJ_NAME} Project # 4 | 5 | ### --- Create project with create-django-app module ### 6 | 7 | First you need to install create-django-app module with bellow credentials 8 | ```sh 9 | $ git clone https://github.com/munisisazade/create-django-app.git 10 | $ cd create-django-app/ 11 | $ python3 install.py 12 | ``` 13 | 14 | ### --- Set up new project with create-django-app module ### 15 | Create new django project with docker container : 16 | ```sh 17 | $ create-django-app app_name 18 | ``` 19 | 20 | This module automaticly create `app_name` file and inside the configured `docker-compose.yml` and `Dockerfile`. 21 | `docker-compose.py`: 22 | ```yaml 23 | version: '3' 24 | 25 | services: 26 | 27 | postgres: 28 | container_name: postgres-db 29 | image: postgres:9.6 30 | ports: 31 | - 5432:5432 # Bind host port 5432 to PostgreSQL port 5432 32 | volumes: 33 | - ./pgdb:/var/lib/postgresql/data 34 | env_file: .env 35 | environment: 36 | - LC_ALL=C.UTF-8 37 | 38 | 39 | # redis: 40 | # image: redis:latest 41 | # restart: "on-failure" 42 | # container_name: redis 43 | # ports: 44 | # - 6379:6379 45 | # volumes: 46 | # - ./redisdb:/var/lib/redis 47 | 48 | 49 | # celery: 50 | # restart: "always" 51 | # build: 52 | # context: . 53 | # dockerfile: celery.dockerfile 54 | # container_name: celery 55 | # env_file: .env 56 | # command: celery --app=#{PROJ_NAME}.celery:app worker -B --loglevel=INFO 57 | # volumes: 58 | # - .:/src 59 | # links: 60 | # - redis 61 | # - postgres 62 | # depends_on: 63 | # - "redis" 64 | # - "postgres" 65 | 66 | 67 | web: 68 | container_name: #{PROJ_NAME} 69 | build: . 70 | restart: "always" 71 | env_file: .env 72 | environment: 73 | - DEBUG=True 74 | - TIMEOUT=300 75 | - HTTP_PORT=#{DOCKER_PORT} 76 | - STATS_PORT=#{DOCKER_PORT} 77 | volumes: 78 | - .:/code 79 | ports: 80 | - "#{DOCKER_PORT}:#{DOCKER_PORT}" 81 | links: 82 | - postgres 83 | depends_on: 84 | - "postgres" 85 | # networks: 86 | # default: 87 | # external: 88 | # name: nginx-proxy 89 | ``` 90 | And `Dockerfile`: 91 | ```yaml 92 | FROM python:3.5 93 | 94 | # Ensure that Python outputs everything that's printed inside 95 | # the application rather than buffering it. 96 | ENV PYTHONUNBUFFERED 1 97 | ENV APP_ROOT /code 98 | 99 | # Copy in your requirements file 100 | ADD requirements.txt /requirements.txt 101 | 102 | # Install build deps, then run `pip install`, then remove unneeded build deps all in a single step. Correct the path to your production requirements file, if needed. 103 | RUN pip install virtualenvwrapper 104 | RUN python3 -m venv /venv 105 | RUN /venv/bin/pip install -U pip 106 | RUN /venv/bin/pip install --no-cache-dir -r /requirements.txt 107 | 108 | # Copy your application code to the container (make sure you create a .dockerignore file if any large files or directories should be excluded) 109 | RUN mkdir ${APP_ROOT} 110 | WORKDIR ${APP_ROOT} 111 | ADD . ${APP_ROOT} 112 | COPY mime.types /etc/mime.types 113 | 114 | # uWSGI will listen on this port 115 | EXPOSE #{DOCKER_PORT} 116 | 117 | # Call collectstatic (customize the following line with the minimal environment variables needed for manage.py to run): 118 | RUN if [ -f manage.py ]; then /venv/bin/python manage.py collectstatic --noinput; fi 119 | 120 | # Start uWSGI 121 | CMD [ "/venv/bin/uwsgi", "--ini", "/code/uwsgi.ini"] 122 | 123 | ``` 124 | 125 | ### --- Build Docker ### 126 | After successfuly created Django app you need to Build docker bellow command: 127 | ```sh 128 | $ cd app_name/ 129 | $ docker-compose build -d 130 | ``` 131 | 132 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 133 | # Django inside Container # 134 | 135 | 136 | ### --- Migrate new Postgres Database ### 137 | 138 | First you need to install Docker Helper commands 139 | ```sh 140 | $ curl -LO https://raw.githubusercontent.com/munisisazade/docker-helper-commands/master/install.sh && bash install.sh 141 | $ connect-docker sh app_name 142 | Command Created by Munis 143 | Connecting with sh inside app_name container with docker command 144 | /code # source /venv/bin/activate 145 | /code # ./manage.py migrate 146 | ``` 147 | 148 | ### --- Backup database ### 149 | 150 | If you want to backup database: 151 | ```sh 152 | $ backup-database-docker 153 | ``` 154 | 155 | ### --- Restore database from dump Sql file ### 156 | 157 | Restore database: 158 | ```sh 159 | $ restore-database-docker 160 | ``` 161 | To create your **app**, make sure you’re in the same directory as manage.py and type this command: 162 | ``` 163 | #! 164 | 165 | $ python manage.py startapp 166 | ``` 167 | 168 | 169 | 170 | ### --- Superuser ### 171 | 172 | Create superusers using the createsuperuser command: 173 | ``` 174 | #! 175 | 176 | $ python manage.py createsuperuser --username=joe --email=joe@example.com 177 | ``` 178 | 179 | 180 | 181 | ### --- Migrate ### 182 | 183 | By running **makemigrations**, you’re telling Django that you’ve made some changes to your models (in this case, you’ve made new ones) and that you’d like the changes to be stored as a *migration*. 184 | 185 | 186 | ``` 187 | #! 188 | 189 | $ python manage.py makemigrations 190 | ``` 191 | 192 | Now, run **migrate** again to create those model tables in your database: 193 | 194 | 195 | ``` 196 | #! 197 | 198 | $ python manage.py migrate 199 | ``` 200 | 201 | 202 | ### --- Running tests ### 203 | 204 | In the terminal, we can run our test: 205 | ``` 206 | #! 207 | $ python manage.py test 208 | ``` 209 | 210 | 211 | 212 | 213 | 214 | 215 | ### --- Shell ### 216 | 217 | To invoke the Python shell, use this command: 218 | ``` 219 | #! 220 | $ python manage.py shell 221 | ``` 222 | 223 | 224 | ### --- Install dependencies ### 225 | 226 | Installing required dependencies on virtual environment: 227 | ``` 228 | #! 229 | $ pip freeze > requirements.txt 230 | $ pip install -r requirements.txt 231 | ``` 232 | 233 | 234 | 235 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 236 | 237 | ### --- Credits & Helpers ### 238 | 1. Extend your RAM by adding a swap file - http://stackoverflow.com/a/18335151/968751 239 | 1. Make ffmpeg executable everywhere - http://askubuntu.com/a/613799 240 | 1. FFMpeg permission denied error - http://askubuntu.com/a/478019 241 | 1. One liner ffmpeg (or other) to get only resolution? - http://askubuntu.com/a/577431 / http://stackoverflow.com/a/29585066 (json) 242 | 1. Revert to a commit by a SHA hash in Git? - http://stackoverflow.com/a/1895095 243 | 244 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 245 | 246 | ### --- Used modules & Apps ### 247 | 1. Media server: [ngnix RMTP](https://github.com/arut/nginx-rtmp-module) 248 | 1. Video edit: [ffmpeg](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) 249 | -------------------------------------------------------------------------------- /tlp/django_app/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, unicode_literals 2 | 3 | # This will make sure the app is always imported when 4 | # Django starts so that shared_task will use this app. 5 | from .celery import app as celery_app 6 | 7 | __all__ = ['celery_app'] -------------------------------------------------------------------------------- /tlp/django_app/app/forms.py: -------------------------------------------------------------------------------- 1 | from django import form 2 | 3 | # Your forms here -------------------------------------------------------------------------------- /tlp/django_app/app/management/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/app/management/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/app/management/commands/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/app/management/commands/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/app/management/commands/ovveride_templates.py: -------------------------------------------------------------------------------- 1 | from django.core.management.base import BaseCommand 2 | from django import get_version as DJANGO_VERSION 3 | from oscar import get_version as OSCAR_VERSION 4 | import subprocess 5 | import sys 6 | import os 7 | 8 | PYTHON_VERSION=sys.version[:3] 9 | COMMAND_VERSION="0.1" 10 | 11 | class Command(BaseCommand): 12 | 13 | def add_arguments(self, parser): 14 | parser.add_argument('venv_path', type=str) 15 | 16 | def handle(self, *args, **options): 17 | # Get Oscar Templates directory 18 | self.usage() 19 | print("Write Virtualenv path") 20 | venv_path = options.get('venv_path', '.venv') 21 | if os.path.exists(venv_path): 22 | subprocess.call("rm -rf $(pwd)/#{APP_NAME}/templates/* && cp -r {}/lib/python{}/site-packages/oscar/templates/oscar/* $(pwd)/#{APP_NAME}/templates && cd #{APP_NAME}/templates && tree".format(venv_path, PYTHON_VERSION),shell=True) 23 | print("Successfuly Ovveride templates") 24 | else: 25 | raise FileExistsError("%s file not found root dir" % venv_path) 26 | 27 | def usage(self): 28 | print("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") 29 | print("\t Oscar Template tools v{}".format(COMMAND_VERSION)) 30 | print("\t Django version v{}".format(DJANGO_VERSION())) 31 | print("\t Oscar version v{}".format(OSCAR_VERSION())) 32 | print("\t Author Munis Isazade - munisisazade@gmail.com") 33 | print("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") 34 | print("Usage: ./manage.py ovveride_templates ") 35 | 36 | -------------------------------------------------------------------------------- /tlp/django_app/app/options/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/app/options/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/app/options/debug.py: -------------------------------------------------------------------------------- 1 | # Author Munis Isazade create log file for Threading 2 | from django.utils import timezone 3 | import os 4 | import sys 5 | import traceback 6 | 7 | VERSION = "0.5.1" 8 | 9 | 10 | class Logger(object): 11 | """ 12 | Logger objects create a log file 13 | if not exist and append string to 14 | log file 15 | """ 16 | 17 | def __init__(self, file='messages.log'): 18 | self.file = file 19 | self.time = timezone.now().strftime('%Y/%m/%d %H:%M:%S') 20 | self.created_time = timezone.now().strftime('%d-%b-%Y %H:%M:%S') 21 | 22 | def debug(self, text=""): 23 | """ 24 | debug check append 25 | method function 26 | :param text: 27 | :return: bool 28 | """ 29 | self._file_append(text) 30 | 31 | def _file_append(self, text=""): 32 | """ 33 | 34 | :param text: 35 | :return: 36 | """ 37 | try: 38 | if self._check_file_exist(self.file): 39 | with open(self.file, "a") as msglog: 40 | msglog.writelines( 41 | "{} Error:[{}] SysInfo:[{}] Time:[{}]\n".format(text, traceback.format_exc(), sys.exc_info()[0], 42 | self.time)) 43 | else: 44 | with open(self.file, "a") as msglog: 45 | msglog.writelines("#Version: {}\n" 46 | "#CreatedDate: {}\n" 47 | "#Author: Munis Isazade\n" 48 | "#Fields: text error sysinfo time\n" 49 | "{} Error:[{}] SysInfo:[{}] Time:[{}]\n".format(self.version(), self.created_time, 50 | text, traceback.format_exc(), 51 | sys.exc_info()[0], self.time)) 52 | return True 53 | except: 54 | raise FileNotFoundError('not found') 55 | 56 | def version(self): 57 | """ 58 | get Logger Module version 59 | """ 60 | return VERSION 61 | 62 | def _check_file_exist(self, filename): 63 | """ 64 | check log file is exist or not 65 | :param filename: 66 | :return: bool 67 | """ 68 | return os.path.isfile(filename) 69 | -------------------------------------------------------------------------------- /tlp/django_app/app/options/task.py: -------------------------------------------------------------------------------- 1 | from .debug import Logger 2 | from threading import Thread 3 | 4 | mylog = Logger() 5 | 6 | 7 | class Task(object): 8 | 9 | def __init__(self, function=None): 10 | """ 11 | Base Async Task Object 12 | Base constructor 13 | """ 14 | self.name = "Task" 15 | self.function = function 16 | 17 | def delay(self, *args): 18 | background_send = Thread(target=self.async, args=(self.function, *args)) 19 | background_send.start() 20 | return print(background_send) 21 | 22 | def async(self, task, *args): 23 | try: 24 | if len(args) == 1: 25 | task(args[0]) 26 | mylog.debug("Successful") 27 | else: 28 | task(*args) 29 | mylog.debug("Successful") 30 | except: 31 | mylog.debug("Error") 32 | 33 | 34 | def shared_task(*args): 35 | try: 36 | base_task = Task(args[0]) 37 | return base_task 38 | except: 39 | task = Task() 40 | return task 41 | -------------------------------------------------------------------------------- /tlp/django_app/app/options/tools.py: -------------------------------------------------------------------------------- 1 | from time import time 2 | 3 | 4 | # Custom slugify function 5 | def slugify(title): 6 | symbol_mapping = ( 7 | (' ', '-'), 8 | ('.', '-'), 9 | (',', '-'), 10 | ('!', '-'), 11 | ('?', '-'), 12 | ("'", '-'), 13 | ('"', '-'), 14 | ('ə', 'e'), 15 | ('ı', 'i'), 16 | ('ö', 'o'), 17 | ('ğ', 'g'), 18 | ('ü', 'u'), 19 | ('ş', 's'), 20 | ('ç', 'c'), 21 | ) 22 | 23 | title_url = title.strip().lower() 24 | 25 | for before, after in symbol_mapping: 26 | title_url = title_url.replace(before, after) 27 | 28 | return title_url 29 | 30 | 31 | def get_doctor_image(instance, filename): 32 | return "doctor/%s_%s" % (str(time()).replace('.', '_'), filename.replace(' ', '_')) 33 | 34 | 35 | def get_home_icons(instance, filename): 36 | return "icons/%s_%s" % (str(time()).replace('.', '_'), filename.replace(' ', '_')) 37 | 38 | 39 | # cover images>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 40 | def get_news_cover(instance, filename): 41 | return "news/%s_%s" % (str(time()).replace('.', '_'), filename.replace(' ', '_')) 42 | 43 | 44 | def get_flatpage_cover(instance, filename): 45 | return "flatpage/%s_%s" % (str(time()).replace('.', '_'), filename.replace(' ', '_')) 46 | 47 | 48 | def get_faq_cover(instance, filename): 49 | return "news/%s_%s" % (str(time()).replace('.', '_'), filename.replace(' ', '_')) 50 | 51 | 52 | def get_doctor_image(instance, filename): 53 | return "doctor/%s_%s" % (str(time()).replace('.', '_'), filename.replace(' ', '_')) 54 | 55 | 56 | def get_departments_cover(instance, filename): 57 | return "news/%s_%s" % (str(time()).replace('.', '_'), filename.replace(' ', '_')) 58 | 59 | 60 | def get_contact_cover(instance, filename): 61 | return "contact/%s_%s" % (str(time()).replace('.', '_'), filename.replace(' ', '_')) 62 | 63 | 64 | def get_cover_path(instance, filename): 65 | return "contact/%s_%s" % (str(time()).replace('.', '_'), filename.replace(' ', '_')) 66 | # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 67 | -------------------------------------------------------------------------------- /tlp/django_app/app/signals.py: -------------------------------------------------------------------------------- 1 | from django.db.models.signals import post_save, pre_delete 2 | 3 | 4 | # example of signal 5 | # @receiver(post_save,sender=,dispatch_uid='') 6 | # def (sender,**kwargs): 7 | # print(kwargs.get('instance')) # get Model object 8 | 9 | -------------------------------------------------------------------------------- /tlp/django_app/app/tasks.py: -------------------------------------------------------------------------------- 1 | # from __future__ import absolute_import, unicode_literals 2 | # from celery import shared_task 3 | 4 | # Use celery shared_task documentation here 5 | # http://docs.celeryproject.org/en/latest/faq.html -------------------------------------------------------------------------------- /tlp/django_app/app/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | # from .views import BaseIndexView 3 | 4 | 5 | urlpatterns = [ 6 | # url(r'^$', BaseIndexView.as_view(), name="index"), 7 | ] -------------------------------------------------------------------------------- /tlp/django_app/base_user/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/base_user/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/base_user/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from base_user.forms import MyUserChangeForm, MyUserCreationForm 3 | from django.contrib.auth.admin import UserAdmin 4 | from django.utils.translation import ugettext_lazy as _ 5 | from django.contrib.auth import get_user_model 6 | 7 | User = get_user_model() 8 | 9 | 10 | @admin.register(User) 11 | class MyUserAdmin(UserAdmin): 12 | fieldsets = ( 13 | (None, {'fields': ('username', 'password')}), 14 | (_('Personal info'), {'fields': ( 15 | 'first_name', 'last_name', 'email', 16 | 'gender')}), 17 | (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 18 | 'groups', 'user_permissions')}), 19 | (_('Important dates'), {'fields': ('last_login', 'date_joined')}), 20 | ) 21 | add_fieldsets = ( 22 | (None, { 23 | 'classes': ('wide',), 24 | 'fields': ("first_name", "last_name", 'username', 'password1', 'password2'), 25 | }), 26 | ) 27 | # The forms to add and change user instances 28 | form = MyUserChangeForm 29 | add_form = MyUserCreationForm 30 | list_display = ('email', 'first_name', 'last_name', 'is_staff') 31 | list_filter = ('is_staff', 'is_superuser', 'is_active', 'groups') 32 | search_fields = ('first_name', 'last_name', 'username', 'email') 33 | ordering = ('-date_joined',) 34 | filter_horizontal = ('groups', 'user_permissions',) 35 | -------------------------------------------------------------------------------- /tlp/django_app/base_user/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BaseUserConfig(AppConfig): 5 | name = 'base_user' 6 | verbose_name = "Istifadəçilər" 7 | -------------------------------------------------------------------------------- /tlp/django_app/base_user/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.contrib.auth import get_user_model 3 | from django.forms import ModelForm 4 | from django.utils.translation import ugettext_lazy as _ 5 | from django.contrib.auth.forms import ReadOnlyPasswordHashField, AuthenticationForm 6 | from django.contrib.auth import authenticate 7 | 8 | from PIL import Image 9 | 10 | # get custom user 11 | User = get_user_model() 12 | 13 | 14 | class MyUserCreationForm(forms.ModelForm): 15 | """ 16 | A form that creates a user, with no privileges, from the given email and 17 | password. 18 | """ 19 | error_messages = { 20 | 'password_mismatch': _("The two password fields didn't match."), 21 | } 22 | password1 = forms.CharField(label=_("Password"), 23 | widget=forms.PasswordInput) 24 | password2 = forms.CharField(label=_("Password confirmation"), 25 | widget=forms.PasswordInput, 26 | help_text=_("Enter the same password as above, for verification.")) 27 | 28 | class Meta: 29 | model = User 30 | fields = ("username", "email", "first_name", "last_name") 31 | 32 | def clean_password2(self): 33 | password1 = self.cleaned_data.get("password1") 34 | password2 = self.cleaned_data.get("password2") 35 | if password1 and password2 and password1 != password2: 36 | raise forms.ValidationError( 37 | self.error_messages['password_mismatch'], 38 | code='password_mismatch', 39 | ) 40 | return password2 41 | 42 | def save(self, commit=True): 43 | user = super(MyUserCreationForm, self).save(commit=False) 44 | user.set_password(self.cleaned_data["password1"]) 45 | if commit: 46 | user.save() 47 | return user 48 | 49 | 50 | class MyUserChangeForm(forms.ModelForm): 51 | password = ReadOnlyPasswordHashField(label=_("Password"), 52 | help_text=_( 53 | "Raw şifrələr bazada saxlanmır, onları heç cürə görmək mümkün deyil " 54 | "bu istifadəçinin şifrəsidir, lakin siz onu dəyişə bilərsiziniz " 55 | " bu form. vasitəsilə")) 56 | 57 | class Meta: 58 | model = User 59 | fields = '__all__' 60 | 61 | def __init__(self, *args, **kwargs): 62 | super(MyUserChangeForm, self).__init__(*args, **kwargs) 63 | f = self.fields.get('user_permissions', None) 64 | if f is not None: 65 | f.queryset = f.queryset.select_related('content_type') 66 | 67 | def clean_password(self): 68 | # Regardless of what the user provides, return the initial value. 69 | # This is done here, rather than on the field, because the 70 | # field does not have access to the initial value 71 | return self.initial["password"] -------------------------------------------------------------------------------- /tlp/django_app/base_user/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/base_user/migrations/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/base_user/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.utils import timezone 3 | from django.conf import settings 4 | from django.core import validators 5 | from django.utils.translation import ugettext_lazy as _ 6 | from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, UserManager 7 | from base_user.tools.common import get_user_profile_photo_file_name, GENDER 8 | 9 | USER_MODEL = settings.AUTH_USER_MODEL 10 | 11 | 12 | # Customize User model 13 | class MyUser(AbstractBaseUser, PermissionsMixin): 14 | """ 15 | An abstract base class implementing a fully featured User model with 16 | admin-compliant permissions. 17 | 18 | Username, password and email are required. Other fields are optional. 19 | """ 20 | 21 | username = models.CharField(_('username'), max_length=100, unique=True, 22 | help_text=_('Tələb olunur. 75 simvol və ya az. Hərflər, Rəqəmlər və ' 23 | '@/./+/-/_ simvollar.'), 24 | validators=[ 25 | validators.RegexValidator(r'^[\w.@+-]+$', _('Düzgün istifadəçi adı daxil edin.'), 26 | 'yanlışdır') 27 | ]) 28 | first_name = models.CharField(_('first name'), max_length=255, blank=True) 29 | last_name = models.CharField(_('last name'), max_length=255, blank=True) 30 | email = models.EmailField(_('email address'), max_length=255) 31 | profile_picture = models.ImageField(upload_to=get_user_profile_photo_file_name, null=True, blank=True) 32 | gender = models.IntegerField(choices=GENDER, verbose_name="cinsi", null=True, blank=True) 33 | 34 | is_staff = models.BooleanField(_('staff status'), default=False, 35 | help_text=_('Designates whether the user can log into this admin ' 36 | 'site.')) 37 | is_active = models.BooleanField(_('active'), default=True, 38 | help_text=_('Designates whether this user should be treated as ' 39 | 'active. Unselect this instead of deleting accounts.')) 40 | date_joined = models.DateTimeField(_('date joined'), default=timezone.now) 41 | 42 | """ 43 | Important non-field stuff 44 | """ 45 | objects = UserManager() 46 | 47 | USERNAME_FIELD = 'username' 48 | REQUIRED_FIELDS = ['email'] 49 | 50 | class Meta: 51 | verbose_name = 'İstifadəçi' 52 | verbose_name_plural = 'İstifadəçilər' 53 | 54 | def get_full_name(self): 55 | """ 56 | Returns the first_name plus the last_name, with a space in between. 57 | """ 58 | full_name = '%s %s' % (self.first_name, self.last_name) 59 | return full_name.strip() 60 | 61 | def get_short_name(self): 62 | """ 63 | Returns the short name for the user. 64 | """ 65 | return self.first_name 66 | 67 | def get_avatar(self): 68 | if self.profile_picture: 69 | try: 70 | return "https://graph.facebook.com/%s/picture?type=large" % self.social_auth.get( 71 | provider='facebook').uid 72 | except: 73 | return "https://graph.facebook.com/%s/picture?type=large" % '100002461198950' 74 | else: 75 | return "https://graph.facebook.com/%s/picture?type=large" % '100002461198950' 76 | -------------------------------------------------------------------------------- /tlp/django_app/base_user/tasks.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/base_user/tasks.py -------------------------------------------------------------------------------- /tlp/django_app/base_user/templatetags/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/base_user/templatetags/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/base_user/templatetags/base_account.py: -------------------------------------------------------------------------------- 1 | from django import template 2 | 3 | register = template.Library() 4 | 5 | 6 | @register.filter 7 | def not_null(arg): 8 | if arg: 9 | return arg 10 | else: 11 | return "" 12 | 13 | @register.filter 14 | def val_int(arg): 15 | return int(arg) 16 | 17 | @register.filter 18 | def val_str(arg): 19 | return str(arg) 20 | 21 | 22 | 23 | @register.filter 24 | def duration_format(value): 25 | days, seconds = value.days, value.seconds 26 | hours = days * 24 + seconds // 3600 27 | minutes = (seconds % 3600) // 60 28 | seconds = (seconds % 60) 29 | return '%s:%s' % (minutes, seconds) -------------------------------------------------------------------------------- /tlp/django_app/base_user/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | 5 | -------------------------------------------------------------------------------- /tlp/django_app/base_user/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/base_user/tools/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/base_user/tools/common.py: -------------------------------------------------------------------------------- 1 | from time import time 2 | import random, string, calendar, datetime 3 | from datetime import date 4 | from django.utils import timezone 5 | from unidecode import unidecode 6 | 7 | def get_user_profile_photo_file_name(instance, filename): 8 | return "profile/%s_%s" % (str(time()).replace('.', '_'), filename) 9 | 10 | 11 | # Models Helper choices here 12 | GENDER = ( 13 | (1, "Man"), 14 | (2, "Woman") 15 | ) 16 | 17 | 18 | # Custom slugify function 19 | def slugify(title): 20 | symbol_mapping = ( 21 | (' ', '-'), 22 | ('.', '-'), 23 | (',', '-'), 24 | ('!', '-'), 25 | ('?', '-'), 26 | ("'", '-'), 27 | ('"', '-'), 28 | ('ə', 'e'), 29 | ('ı', 'i'), 30 | ('ö', 'o'), 31 | ('ğ', 'g'), 32 | ('ü', 'u'), 33 | ('ş', 's'), 34 | ('ç', 'c'), 35 | ) 36 | title_url = title.strip().lower() 37 | 38 | for before, after in symbol_mapping: 39 | title_url = title_url.replace(before, after) 40 | 41 | return unidecode(title_url) 42 | -------------------------------------------------------------------------------- /tlp/django_app/base_user/tools/decorator.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import redirect 2 | from django.urls import reverse 3 | from django.views.generic import View 4 | 5 | 6 | class LoginRequiredMixinView(View): 7 | """ 8 | This method for base Login required 9 | for view append your new class 10 | """ 11 | def dispatch(self, *args, **kwargs): 12 | if self.request.user.is_authenticated: 13 | return redirect(reverse('base:index')) 14 | else: 15 | return super(LoginRequiredMixinView, self).dispatch(*args, **kwargs) 16 | -------------------------------------------------------------------------------- /tlp/django_app/base_user/tools/logger.py: -------------------------------------------------------------------------------- 1 | # Author Munis Isazade create log file for Threading 2 | from django.utils import timezone 3 | import os 4 | import sys 5 | import traceback 6 | 7 | VERSION = "0.5.1" 8 | 9 | 10 | class Logger(object): 11 | """ 12 | Logger objects create a log file 13 | if not exist and append string to 14 | log file 15 | """ 16 | 17 | def __init__(self, file='messages.log'): 18 | self.file = file 19 | self.time = timezone.now().strftime('%Y/%m/%d %H:%M:%S') 20 | self.created_time = timezone.now().strftime('%d-%b-%Y %H:%M:%S') 21 | 22 | def debug(self, text=""): 23 | """ 24 | debug check append 25 | method function 26 | :param text: 27 | :return: bool 28 | """ 29 | self._file_append(text) 30 | 31 | def _file_append(self, text=""): 32 | """ 33 | 34 | :param text: 35 | :return: 36 | """ 37 | try: 38 | if self._check_file_exist(self.file): 39 | with open(self.file, "a") as msglog: 40 | msglog.writelines( 41 | "{} Error:[{}] SysInfo:[{}] Time:[{}]\n".format(text, traceback.format_exc(), sys.exc_info()[0], 42 | self.time)) 43 | else: 44 | with open(self.file, "a") as msglog: 45 | msglog.writelines("#Version: {}\n" 46 | "#CreatedDate: {}\n" 47 | "#Author: Munis Isazade\n" 48 | "#Fields: text error sysinfo time\n" 49 | "{} Error:[{}] SysInfo:[{}] Time:[{}]\n".format(self.version(), self.created_time, 50 | text, traceback.format_exc(), 51 | sys.exc_info()[0], self.time)) 52 | return True 53 | except: 54 | raise FileNotFoundError('not found') 55 | 56 | def version(self): 57 | """ 58 | get Logger Module version 59 | """ 60 | return VERSION 61 | 62 | def _check_file_exist(self, filename): 63 | """ 64 | check log file is exist or not 65 | :param filename: 66 | :return: bool 67 | """ 68 | return os.path.isfile(filename) 69 | -------------------------------------------------------------------------------- /tlp/django_app/base_user/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | 3 | 4 | urlpatterns = [ 5 | # url(r'^$', BaseSystemLoginView.as_view(), name="login"), 6 | # url(r'^logout/$', auth_views.logout, name="logout", kwargs={'next_page': '/'}), 7 | # url(r'^register/$', RegistrationView.as_view(), name="register"), 8 | 9 | ] -------------------------------------------------------------------------------- /tlp/django_app/base_user/views.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/base_user/views.py -------------------------------------------------------------------------------- /tlp/django_app/celery.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, unicode_literals 2 | from celery import Celery 3 | # from celery.schedules import crontab 4 | import os, logging 5 | from django.conf import settings 6 | 7 | logger = logging.getLogger("Celery") 8 | 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', '#{PROJ_NAME}.settings') 10 | 11 | app = Celery('#{PROJ_NAME}') 12 | 13 | app.config_from_object('django.conf:settings', namespace='CELERY') 14 | app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) 15 | 16 | 17 | @app.task(bind=True) 18 | def debug_task(self): 19 | print('Request: {0!r}'.format(self.request)) 20 | 21 | 22 | if settings.PROD: 23 | app.conf.update( 24 | BROKER_URL='redis://:{password}@redis:6379/0'.format(password=os.environ.get("REDIS_PASSWORD")), 25 | CELERYBEAT_SCHEDULER='django_celery_beat.schedulers:DatabaseScheduler', 26 | CELERY_RESULT_BACKEND='redis://:{password}@redis:6379/1'.format(password=os.environ.get("REDIS_PASSWORD")), 27 | CELERY_DISABLE_RATE_LIMITS=True, 28 | CELERY_ACCEPT_CONTENT=['json', ], 29 | CELERY_TASK_SERIALIZER='json', 30 | CELERY_RESULT_SERIALIZER='json', 31 | ) 32 | else: 33 | app.conf.update( 34 | BROKER_URL='redis://localhost:6379/0', 35 | CELERYBEAT_SCHEDULER='django_celery_beat.schedulers:DatabaseScheduler', 36 | CELERY_RESULT_BACKEND='redis://localhost:6379/1', 37 | CELERY_DISABLE_RATE_LIMITS=True, 38 | CELERY_ACCEPT_CONTENT=['json', ], 39 | CELERY_TASK_SERIALIZER='json', 40 | CELERY_RESULT_SERIALIZER='json', 41 | ) 42 | # 43 | # app.conf.beat_schedule = { 44 | # 'every_week_update_leaderboard': { 45 | # 'task': 'game.tasks.update_leaderboard', 46 | # 'schedule': crontab(hour=0, minute=1), 47 | # }, 48 | # } 49 | -------------------------------------------------------------------------------- /tlp/django_app/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | 5 | postgres: 6 | container_name: postgres-db 7 | image: postgres:9.6.6 8 | ports: 9 | - 5432:5432 # Bind host port 5432 to PostgreSQL port 5432 10 | volumes: 11 | - ../pgdb:/var/lib/postgresql/data 12 | env_file: ../.env 13 | environment: 14 | - LC_ALL=C.UTF-8 15 | 16 | # redis: 17 | # image: redis:4.0.11 18 | # restart: "on-failure" 19 | # container_name: redis 20 | # ports: 21 | # - 6379:6379 22 | # volumes: 23 | # - ../redisdb:/var/lib/redis 24 | 25 | # celery: 26 | # restart: "always" 27 | # build: 28 | # context: . 29 | # dockerfile: ../celery.dockerfile 30 | # container_name: celery 31 | # env_file: ../.env 32 | # command: celery --app=starex.celery:app worker -B --loglevel=INFO 33 | # volumes: 34 | # - ../:/src 35 | # links: 36 | # - redis 37 | # - postgres 38 | # depends_on: 39 | # - "redis" 40 | # - "postgres" 41 | 42 | networks: 43 | default: 44 | external: 45 | name: nginx-proxy 46 | -------------------------------------------------------------------------------- /tlp/django_app/middleware/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/middleware/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/middleware/force_default_middleware.py: -------------------------------------------------------------------------------- 1 | def force_default_language_middleware(get_response): 2 | """ 3 | Ignore Accept-Language HTTP headers 4 | 5 | This will force the I18N machinery to always choose settings.LANGUAGE_CODE 6 | as the default initial language, unless another one is set via sessions or cookies 7 | 8 | Should be installed *before* any middleware that checks request.META['HTTP_ACCEPT_LANGUAGE'], 9 | namely django.middleware.locale.LocaleMiddleware 10 | """ 11 | 12 | # One-time configuration and initialization. 13 | 14 | def middleware(request): 15 | # Code to be executed for each request before 16 | # the view (and later middleware) are called. 17 | if 'HTTP_ACCEPT_LANGUAGE' in request.META: 18 | del request.META['HTTP_ACCEPT_LANGUAGE'] 19 | 20 | response = get_response(request) 21 | 22 | # Code to be executed for each request/response after 23 | # the view is called. 24 | 25 | return response 26 | 27 | return middleware 28 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/oscar_apps/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/__init__.py: -------------------------------------------------------------------------------- 1 | default_app_config = 'oscar_apps.basket.config.BasketConfig' 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/admin.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.basket.admin import * # noqa 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/app.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.basket import app as basket_app 2 | from .views import BasketAddView 3 | 4 | 5 | class OscarBasketApplication(basket_app.BasketApplication): 6 | add_view = BasketAddView 7 | 8 | 9 | application = OscarBasketApplication() 10 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/config.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.basket import config 2 | 3 | 4 | class BasketConfig(config.BasketConfig): 5 | name = 'oscar_apps.basket' 6 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ] 11 | 12 | operations = [ 13 | migrations.CreateModel( 14 | name='Basket', 15 | fields=[ 16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 17 | ('status', models.CharField(default='Open', max_length=128, verbose_name='Status', choices=[('Open', 'Open - currently active'), ('Merged', 'Merged - superceded by another basket'), ('Saved', 'Saved - for items to be purchased later'), ('Frozen', 'Frozen - the basket cannot be modified'), ('Submitted', 'Submitted - has been ordered at the checkout')])), 18 | ('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Date created')), 19 | ('date_merged', models.DateTimeField(blank=True, verbose_name='Date merged', null=True)), 20 | ('date_submitted', models.DateTimeField(blank=True, verbose_name='Date submitted', null=True)), 21 | ], 22 | options={ 23 | 'verbose_name_plural': 'Baskets', 24 | 'verbose_name': 'Basket', 25 | 'abstract': False, 26 | }, 27 | bases=(models.Model,), 28 | ), 29 | migrations.CreateModel( 30 | name='Line', 31 | fields=[ 32 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 33 | ('line_reference', models.SlugField(max_length=128, verbose_name='Line Reference')), 34 | ('quantity', models.PositiveIntegerField(default=1, verbose_name='Quantity')), 35 | ('price_currency', models.CharField(default='GBP', max_length=12, verbose_name='Currency')), 36 | ('price_excl_tax', models.DecimalField(max_digits=12, decimal_places=2, verbose_name='Price excl. Tax', null=True)), 37 | ('price_incl_tax', models.DecimalField(max_digits=12, decimal_places=2, verbose_name='Price incl. Tax', null=True)), 38 | ('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Date Created')), 39 | ], 40 | options={ 41 | 'verbose_name_plural': 'Basket lines', 42 | 'verbose_name': 'Basket line', 43 | 'abstract': False, 44 | }, 45 | bases=(models.Model,), 46 | ), 47 | migrations.CreateModel( 48 | name='LineAttribute', 49 | fields=[ 50 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 51 | ('value', models.CharField(max_length=255, verbose_name='Value')), 52 | ('line', models.ForeignKey(verbose_name='Line', related_name='attributes', to='basket.Line', on_delete=models.CASCADE)), 53 | ], 54 | options={ 55 | 'verbose_name_plural': 'Line attributes', 56 | 'verbose_name': 'Line attribute', 57 | 'abstract': False, 58 | }, 59 | bases=(models.Model,), 60 | ), 61 | ] 62 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/migrations/0002_auto_20140827_1705.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | from django.conf import settings 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('partner', '0001_initial'), 12 | ('catalogue', '0001_initial'), 13 | ('basket', '0001_initial'), 14 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 15 | ] 16 | 17 | operations = [ 18 | migrations.AddField( 19 | model_name='lineattribute', 20 | name='option', 21 | field=models.ForeignKey(verbose_name='Option', to='catalogue.Option', on_delete=models.CASCADE), 22 | preserve_default=True, 23 | ), 24 | migrations.AddField( 25 | model_name='line', 26 | name='basket', 27 | field=models.ForeignKey(verbose_name='Basket', related_name='lines', to='basket.Basket', on_delete=models.CASCADE), 28 | preserve_default=True, 29 | ), 30 | migrations.AddField( 31 | model_name='line', 32 | name='product', 33 | field=models.ForeignKey(verbose_name='Product', related_name='basket_lines', to='catalogue.Product', on_delete=models.CASCADE), 34 | preserve_default=True, 35 | ), 36 | migrations.AddField( 37 | model_name='line', 38 | name='stockrecord', 39 | field=models.ForeignKey(related_name='basket_lines', to='partner.StockRecord', on_delete=models.CASCADE), 40 | preserve_default=True, 41 | ), 42 | migrations.AlterUniqueTogether( 43 | name='line', 44 | unique_together=set([('basket', 'line_reference')]), 45 | ), 46 | migrations.AddField( 47 | model_name='basket', 48 | name='owner', 49 | field=models.ForeignKey(verbose_name='Owner', related_name='baskets', to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE), 50 | preserve_default=True, 51 | ), 52 | ] 53 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/migrations/0003_basket_vouchers.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('voucher', '0001_initial'), 11 | ('basket', '0002_auto_20140827_1705'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AddField( 16 | model_name='basket', 17 | name='vouchers', 18 | field=models.ManyToManyField(blank=True, verbose_name='Vouchers', to='voucher.Voucher', null=True), 19 | preserve_default=True, 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/migrations/0004_auto_20141007_2032.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | import oscar.core.utils 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('basket', '0003_basket_vouchers'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AlterField( 16 | model_name='line', 17 | name='price_currency', 18 | field=models.CharField(default=oscar.core.utils.get_default_currency, max_length=12, verbose_name='Currency'), 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/migrations/0005_auto_20150604_1450.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('basket', '0004_auto_20141007_2032'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterField( 15 | model_name='basket', 16 | name='vouchers', 17 | field=models.ManyToManyField(to='voucher.Voucher', verbose_name='Vouchers', blank=True), 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/migrations/0006_auto_20160111_1108.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('basket', '0005_auto_20150604_1450'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterModelOptions( 15 | name='line', 16 | options={'ordering': ['date_created', 'pk'], 'verbose_name': 'Basket line', 'verbose_name_plural': 'Basket lines'}, 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/migrations/0007_slugfield_noop.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9.7 on 2016-07-13 08:44 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | import oscar.models.fields.slugfield 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | ('basket', '0006_auto_20160111_1108'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AlterField( 17 | model_name='line', 18 | name='line_reference', 19 | field=oscar.models.fields.slugfield.SlugField(max_length=128, verbose_name='Line Reference'), 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/oscar_apps/basket/migrations/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/models.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.basket.models import * # noqa isort:skip 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/basket/views.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.basket import views as basket_views 2 | from django.http import JsonResponse 3 | 4 | 5 | class BasketAddView(basket_views.BasketAddView): 6 | def form_valid(self, form): 7 | offers_before = self.request.basket.applied_offers() 8 | 9 | self.request.basket.add_product( 10 | form.product, form.cleaned_data['quantity'], 11 | form.cleaned_options()) 12 | 13 | basket_views.messages.success(self.request, self.get_success_message(form), 14 | extra_tags='safe noicon') 15 | 16 | # Check for additional offer messages 17 | basket_views.BasketMessageGenerator().apply_messages(self.request, offers_before) 18 | 19 | # Send signal for basket addition 20 | self.add_signal.send( 21 | sender=self, product=form.product, user=self.request.user, 22 | request=self.request) 23 | line_id = self.request.basket.all_lines().last().id 24 | # if form.product.is_parent: 25 | attributes = form.product.attribute_values.all() 26 | _attributes = {} 27 | for av in attributes: 28 | if av.attribute.code == 'color' or av.attribute.code == 'type': 29 | if hasattr(av.value, "option"): 30 | _attributes[av.attribute.code] = av.value.option 31 | else: 32 | pass 33 | 34 | return JsonResponse({ 35 | "line_id": line_id, 36 | "attributes": _attributes, 37 | "quantity": form.cleaned_data['quantity'] 38 | }) 39 | # else: 40 | # return JsonResponse({"line_id": line_id}) 41 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/__init__.py: -------------------------------------------------------------------------------- 1 | default_app_config = 'oscar_apps.catalogue.config.CatalogueConfig' 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/admin.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.catalogue.admin import * # noqa 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/app.py: -------------------------------------------------------------------------------- 1 | # from oscar.apps.catalogue import app as catalogue_app 2 | # from .views import ProductCategoryView 3 | # 4 | # 5 | # class CatalogueApp(catalogue_app.CatalogueApplication): 6 | # category_view = ProductCategoryView 7 | # 8 | # 9 | # application = CatalogueApp() 10 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/config.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.catalogue import config 2 | 3 | 4 | class CatalogueConfig(config.CatalogueConfig): 5 | name = 'oscar_apps.catalogue' 6 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | import oscar.models.fields.autoslugfield 6 | import django.db.models.deletion 7 | import django.core.validators 8 | import oscar.models.fields 9 | 10 | 11 | class Migration(migrations.Migration): 12 | 13 | dependencies = [ 14 | ('contenttypes', '0001_initial'), 15 | ] 16 | 17 | operations = [ 18 | migrations.CreateModel( 19 | name='AttributeOption', 20 | fields=[ 21 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 22 | ('option', models.CharField(max_length=255, verbose_name='Option')), 23 | ], 24 | options={ 25 | 'verbose_name_plural': 'Attribute options', 26 | 'verbose_name': 'Attribute option', 27 | 'abstract': False, 28 | }, 29 | bases=(models.Model,), 30 | ), 31 | migrations.CreateModel( 32 | name='AttributeOptionGroup', 33 | fields=[ 34 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 35 | ('name', models.CharField(max_length=128, verbose_name='Name')), 36 | ], 37 | options={ 38 | 'verbose_name_plural': 'Attribute option groups', 39 | 'verbose_name': 'Attribute option group', 40 | 'abstract': False, 41 | }, 42 | bases=(models.Model,), 43 | ), 44 | migrations.CreateModel( 45 | name='Category', 46 | fields=[ 47 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 48 | ('path', models.CharField(unique=True, max_length=255)), 49 | ('depth', models.PositiveIntegerField()), 50 | ('numchild', models.PositiveIntegerField(default=0)), 51 | ('name', models.CharField(max_length=255, db_index=True, verbose_name='Name')), 52 | ('description', models.TextField(verbose_name='Description', blank=True)), 53 | ('image', models.ImageField(upload_to='categories', verbose_name='Image', max_length=255, blank=True, null=True)), 54 | ('slug', models.SlugField(max_length=255, editable=False, verbose_name='Slug')), 55 | ('full_name', models.CharField(max_length=255, editable=False, db_index=True, verbose_name='Full Name')), 56 | ], 57 | options={ 58 | 'ordering': ['full_name'], 59 | 'verbose_name_plural': 'Categories', 60 | 'verbose_name': 'Category', 61 | 'abstract': False, 62 | }, 63 | bases=(models.Model,), 64 | ), 65 | migrations.CreateModel( 66 | name='Option', 67 | fields=[ 68 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 69 | ('name', models.CharField(max_length=128, verbose_name='Name')), 70 | ('code', oscar.models.fields.autoslugfield.AutoSlugField(populate_from='name', unique=True, verbose_name='Code', max_length=128, editable=False, blank=True)), 71 | ('type', models.CharField(default='Required', max_length=128, verbose_name='Status', choices=[('Required', 'Required - a value for this option must be specified'), ('Optional', 'Optional - a value for this option can be omitted')])), 72 | ], 73 | options={ 74 | 'verbose_name_plural': 'Options', 75 | 'verbose_name': 'Option', 76 | 'abstract': False, 77 | }, 78 | bases=(models.Model,), 79 | ), 80 | migrations.CreateModel( 81 | name='Product', 82 | fields=[ 83 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 84 | ('structure', models.CharField(default='standalone', max_length=10, verbose_name='Product structure', choices=[('standalone', 'Stand-alone product'), ('parent', 'Parent product'), ('child', 'Child product')])), 85 | ('upc', oscar.models.fields.NullCharField(unique=True, verbose_name='UPC', max_length=64, help_text='Universal Product Code (UPC) is an identifier for a product which is not specific to a particular supplier. Eg an ISBN for a book.')), 86 | ('title', models.CharField(max_length=255, verbose_name='Title', blank=True)), 87 | ('slug', models.SlugField(max_length=255, verbose_name='Slug')), 88 | ('description', models.TextField(verbose_name='Description', blank=True)), 89 | ('rating', models.FloatField(editable=False, verbose_name='Rating', null=True)), 90 | ('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Date created')), 91 | ('date_updated', models.DateTimeField(auto_now=True, db_index=True, verbose_name='Date updated')), 92 | ('is_discountable', models.BooleanField(default=True, verbose_name='Is discountable?', help_text='This flag indicates if this product can be used in an offer or not')), 93 | ], 94 | options={ 95 | 'ordering': ['-date_created'], 96 | 'verbose_name_plural': 'Products', 97 | 'verbose_name': 'Product', 98 | 'abstract': False, 99 | }, 100 | bases=(models.Model,), 101 | ), 102 | migrations.CreateModel( 103 | name='ProductAttribute', 104 | fields=[ 105 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 106 | ('name', models.CharField(max_length=128, verbose_name='Name')), 107 | ('code', models.SlugField(max_length=128, verbose_name='Code', validators=[django.core.validators.RegexValidator(regex='^[a-zA-Z\\-_][0-9a-zA-Z\\-_]*$', message="Code can only contain the letters a-z, A-Z, digits, minus and underscores, and can't start with a digit")])), 108 | ('type', models.CharField(default='text', max_length=20, verbose_name='Type', choices=[('text', 'Text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('richtext', 'Rich Text'), ('date', 'Date'), ('option', 'Option'), ('entity', 'Entity'), ('file', 'File'), ('image', 'Image')])), 109 | ('required', models.BooleanField(default=False, verbose_name='Required')), 110 | ('option_group', models.ForeignKey(null=True, verbose_name='Option Group', help_text='Select an option group if using type "Option"', to='catalogue.AttributeOptionGroup', blank=True, on_delete=models.CASCADE)), 111 | ], 112 | options={ 113 | 'ordering': ['code'], 114 | 'verbose_name_plural': 'Product attributes', 115 | 'verbose_name': 'Product attribute', 116 | 'abstract': False, 117 | }, 118 | bases=(models.Model,), 119 | ), 120 | migrations.CreateModel( 121 | name='ProductAttributeValue', 122 | fields=[ 123 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 124 | ('value_text', models.TextField(blank=True, verbose_name='Text', null=True)), 125 | ('value_integer', models.IntegerField(blank=True, verbose_name='Integer', null=True)), 126 | ('value_boolean', models.NullBooleanField(verbose_name='Boolean')), 127 | ('value_float', models.FloatField(blank=True, verbose_name='Float', null=True)), 128 | ('value_richtext', models.TextField(blank=True, verbose_name='Richtext', null=True)), 129 | ('value_date', models.DateField(blank=True, verbose_name='Date', null=True)), 130 | ('value_file', models.FileField(upload_to='images/products/%Y/%m/', max_length=255, blank=True, null=True)), 131 | ('value_image', models.ImageField(upload_to='images/products/%Y/%m/', max_length=255, blank=True, null=True)), 132 | ('entity_object_id', models.PositiveIntegerField(blank=True, editable=False, null=True)), 133 | ('attribute', models.ForeignKey(verbose_name='Attribute', to='catalogue.ProductAttribute', on_delete=models.CASCADE)), 134 | ('entity_content_type', models.ForeignKey(null=True, editable=False, to='contenttypes.ContentType', blank=True, on_delete=models.CASCADE)), 135 | ('product', models.ForeignKey(verbose_name='Product', related_name='attribute_values', to='catalogue.Product', on_delete=models.CASCADE)), 136 | ('value_option', models.ForeignKey(null=True, verbose_name='Value option', to='catalogue.AttributeOption', blank=True, on_delete=models.CASCADE)), 137 | ], 138 | options={ 139 | 'verbose_name_plural': 'Product attribute values', 140 | 'verbose_name': 'Product attribute value', 141 | 'abstract': False, 142 | }, 143 | bases=(models.Model,), 144 | ), 145 | migrations.CreateModel( 146 | name='ProductCategory', 147 | fields=[ 148 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 149 | ('category', models.ForeignKey(verbose_name='Category', to='catalogue.Category', on_delete=models.CASCADE)), 150 | ('product', models.ForeignKey(verbose_name='Product', to='catalogue.Product', on_delete=models.CASCADE)), 151 | ], 152 | options={ 153 | 'ordering': ['product', 'category'], 154 | 'verbose_name_plural': 'Product categories', 155 | 'verbose_name': 'Product category', 156 | 'abstract': False, 157 | }, 158 | bases=(models.Model,), 159 | ), 160 | migrations.CreateModel( 161 | name='ProductClass', 162 | fields=[ 163 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 164 | ('name', models.CharField(max_length=128, verbose_name='Name')), 165 | ('slug', oscar.models.fields.autoslugfield.AutoSlugField(populate_from='name', unique=True, verbose_name='Slug', max_length=128, editable=False, blank=True)), 166 | ('requires_shipping', models.BooleanField(default=True, verbose_name='Requires shipping?')), 167 | ('track_stock', models.BooleanField(default=True, verbose_name='Track stock levels?')), 168 | ('options', models.ManyToManyField(verbose_name='Options', to='catalogue.Option', blank=True)), 169 | ], 170 | options={ 171 | 'ordering': ['name'], 172 | 'verbose_name_plural': 'Product classes', 173 | 'verbose_name': 'Product class', 174 | 'abstract': False, 175 | }, 176 | bases=(models.Model,), 177 | ), 178 | migrations.CreateModel( 179 | name='ProductImage', 180 | fields=[ 181 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 182 | ('original', models.ImageField(upload_to='images/products/%Y/%m/', max_length=255, verbose_name='Original')), 183 | ('caption', models.CharField(max_length=200, verbose_name='Caption', blank=True)), 184 | ('display_order', models.PositiveIntegerField(default=0, verbose_name='Display order', help_text='An image with a display order of zero will be the primary image for a product')), 185 | ('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Date created')), 186 | ('product', models.ForeignKey(verbose_name='Product', related_name='images', to='catalogue.Product', on_delete=models.CASCADE)), 187 | ], 188 | options={ 189 | 'ordering': ['display_order'], 190 | 'verbose_name_plural': 'Product images', 191 | 'verbose_name': 'Product image', 192 | 'abstract': False, 193 | }, 194 | bases=(models.Model,), 195 | ), 196 | migrations.CreateModel( 197 | name='ProductRecommendation', 198 | fields=[ 199 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 200 | ('ranking', models.PositiveSmallIntegerField(default=0, verbose_name='Ranking', help_text='Determines order of the products. A product with a higher value will appear before one with a lower ranking.')), 201 | ('primary', models.ForeignKey(verbose_name='Primary product', related_name='primary_recommendations', to='catalogue.Product', on_delete=models.CASCADE)), 202 | ('recommendation', models.ForeignKey(verbose_name='Recommended product', to='catalogue.Product', on_delete=models.CASCADE)), 203 | ], 204 | options={ 205 | 'ordering': ['primary', '-ranking'], 206 | 'verbose_name_plural': 'Product recomendations', 207 | 'verbose_name': 'Product recommendation', 208 | 'abstract': False, 209 | }, 210 | bases=(models.Model,), 211 | ), 212 | migrations.AlterUniqueTogether( 213 | name='productrecommendation', 214 | unique_together=set([('primary', 'recommendation')]), 215 | ), 216 | migrations.AlterUniqueTogether( 217 | name='productimage', 218 | unique_together=set([('product', 'display_order')]), 219 | ), 220 | migrations.AlterUniqueTogether( 221 | name='productcategory', 222 | unique_together=set([('product', 'category')]), 223 | ), 224 | migrations.AlterUniqueTogether( 225 | name='productattributevalue', 226 | unique_together=set([('attribute', 'product')]), 227 | ), 228 | migrations.AddField( 229 | model_name='productattribute', 230 | name='product_class', 231 | field=models.ForeignKey(null=True, verbose_name='Product type', related_name='attributes', to='catalogue.ProductClass', blank=True, on_delete=models.CASCADE), 232 | preserve_default=True, 233 | ), 234 | migrations.AddField( 235 | model_name='product', 236 | name='attributes', 237 | field=models.ManyToManyField(verbose_name='Attributes', help_text='A product attribute is something that this product may have, such as a size, as specified by its class', to='catalogue.ProductAttribute', through='catalogue.ProductAttributeValue'), 238 | preserve_default=True, 239 | ), 240 | migrations.AddField( 241 | model_name='product', 242 | name='categories', 243 | field=models.ManyToManyField(through='catalogue.ProductCategory', verbose_name='Categories', to='catalogue.Category'), 244 | preserve_default=True, 245 | ), 246 | migrations.AddField( 247 | model_name='product', 248 | name='parent', 249 | field=models.ForeignKey(null=True, verbose_name='Parent product', related_name='children', help_text="Only choose a parent product if you're creating a child product. For example if this is a size 4 of a particular t-shirt. Leave blank if this is a stand-alone product (i.e. there is only one version of this product).", to='catalogue.Product', blank=True, on_delete=models.CASCADE), 250 | preserve_default=True, 251 | ), 252 | migrations.AddField( 253 | model_name='product', 254 | name='product_class', 255 | field=models.ForeignKey(verbose_name='Product type', on_delete=django.db.models.deletion.PROTECT, related_name='products', help_text='Choose what type of product this is', to='catalogue.ProductClass', null=True), 256 | preserve_default=True, 257 | ), 258 | migrations.AddField( 259 | model_name='product', 260 | name='product_options', 261 | field=models.ManyToManyField(verbose_name='Product options', help_text="Options are values that can be associated with a item when it is added to a customer's basket. This could be something like a personalised message to be printed on a T-shirt.", to='catalogue.Option', blank=True), 262 | preserve_default=True, 263 | ), 264 | migrations.AddField( 265 | model_name='product', 266 | name='recommended_products', 267 | field=models.ManyToManyField(verbose_name='Recommended products', help_text='These are products that are recommended to accompany the main product.', to='catalogue.Product', through='catalogue.ProductRecommendation', blank=True), 268 | preserve_default=True, 269 | ), 270 | migrations.AddField( 271 | model_name='attributeoption', 272 | name='group', 273 | field=models.ForeignKey(verbose_name='Group', related_name='options', to='catalogue.AttributeOptionGroup', on_delete=models.CASCADE), 274 | preserve_default=True, 275 | ), 276 | ] 277 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0002_auto_20150217_1221.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('catalogue', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterModelOptions( 15 | name='category', 16 | options={'ordering': ['path'], 'verbose_name': 'Category', 'verbose_name_plural': 'Categories'}, 17 | ), 18 | migrations.RemoveField( 19 | model_name='category', 20 | name='full_name', 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0003_data_migration_slugs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | 6 | from oscar.core.loading import get_model 7 | 8 | # Django database migrations require us to fetch the category model 9 | # via apps.get_model to get an instance of the model at this point 10 | # in time of migrations. That snapshot does not expose custom 11 | # properties, only whatever is represented in the migration files. 12 | # But because for our slug munging below, we need to know the slug 13 | # separator, which is a custom property, we also load the actual 14 | # ORM model. We MUST NOT use that to save data, we just fetch 15 | # the property. 16 | 17 | ORMCategory = get_model('catalogue', 'Category') 18 | 19 | 20 | def remove_ancestor_slugs(apps, schema_editor): 21 | MigrationCategory = apps.get_model('catalogue', 'Category') 22 | for category in MigrationCategory.objects.all(): 23 | category.slug = category.slug.split(ORMCategory._slug_separator)[-1] 24 | category.save() 25 | 26 | 27 | def add_ancestor_slugs(apps, schema_editor): 28 | MigrationCategory = apps.get_model('catalogue', 'Category') 29 | for category in MigrationCategory.objects.all(): 30 | orm_category = ORMCategory.objects.get(pk=category.pk) 31 | category.slug = orm_category.full_slug 32 | category.save() 33 | 34 | 35 | class Migration(migrations.Migration): 36 | 37 | dependencies = [ 38 | ('catalogue', '0002_auto_20150217_1221'), 39 | ] 40 | 41 | operations = [ 42 | migrations.RunPython(remove_ancestor_slugs, add_ancestor_slugs), 43 | ] 44 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0004_auto_20150217_1710.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('catalogue', '0003_data_migration_slugs'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterField( 15 | model_name='category', 16 | name='slug', 17 | field=models.SlugField(max_length=255, verbose_name='Slug'), 18 | preserve_default=True, 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0005_auto_20150604_1450.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('catalogue', '0004_auto_20150217_1710'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AlterField( 16 | model_name='product', 17 | name='product_class', 18 | field=models.ForeignKey(related_name='products', on_delete=django.db.models.deletion.PROTECT, blank=True, to='catalogue.ProductClass', help_text='Choose what type of product this is', null=True, verbose_name='Product type'), 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0006_auto_20150807_1725.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | import django.core.validators 6 | import oscar.core.validators 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | ('catalogue', '0005_auto_20150604_1450'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AlterField( 17 | model_name='productattribute', 18 | name='code', 19 | field=models.SlugField(max_length=128, verbose_name='Code', validators=[django.core.validators.RegexValidator(regex=r'^[a-zA-Z_][0-9a-zA-Z_]*$', message="Code can only contain the letters a-z, A-Z, digits, and underscores, and can't start with a digit"), oscar.core.validators.non_python_keyword]), 20 | preserve_default=True, 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0007_auto_20151207_1440.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import migrations, models 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('catalogue', '0006_auto_20150807_1725'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterUniqueTogether( 15 | name='attributeoption', 16 | unique_together=set([('group', 'option')]), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0008_auto_20160304_1652.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import migrations, models 5 | import django.core.validators 6 | import oscar.core.validators 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | ('catalogue', '0007_auto_20151207_1440'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AlterField( 17 | model_name='productattribute', 18 | name='code', 19 | field=models.SlugField(max_length=128, verbose_name='Code', validators=[django.core.validators.RegexValidator(regex=r'^[a-zA-Z_][0-9a-zA-Z_]*$', message="Code can only contain the letters a-z, A-Z, digits, and underscores, and can't start with a digit."), oscar.core.validators.non_python_keyword]), 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0009_slugfield_noop.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9.7 on 2016-07-13 08:44 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | import oscar.models.fields.slugfield 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | ('catalogue', '0008_auto_20160304_1652'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AlterField( 17 | model_name='category', 18 | name='slug', 19 | field=oscar.models.fields.slugfield.SlugField(max_length=255, verbose_name='Slug'), 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0010_auto_20170420_0439.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11 on 2017-04-20 05:51 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | import django.db.models.deletion 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | ('catalogue', '0009_slugfield_noop'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AddField( 17 | model_name='productattributevalue', 18 | name='value_multi_option', 19 | field=models.ManyToManyField(blank=True, related_name='multi_valued_attribute_values', to='catalogue.AttributeOption', verbose_name='Value multi option'), 20 | ), 21 | migrations.AlterField( 22 | model_name='productattribute', 23 | name='option_group', 24 | field=models.ForeignKey(blank=True, help_text='Select an option group if using type "Option" or "Multi Option"', null=True, on_delete=django.db.models.deletion.CASCADE, to='catalogue.AttributeOptionGroup', verbose_name='Option Group'), 25 | ), 26 | migrations.AlterField( 27 | model_name='productattribute', 28 | name='type', 29 | field=models.CharField(choices=[('text', 'Text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('richtext', 'Rich Text'), ('date', 'Date'), ('option', 'Option'), ('multi_option', 'Multi Option'), ('entity', 'Entity'), ('file', 'File'), ('image', 'Image')], default='text', max_length=20, verbose_name='Type'), 30 | ), 31 | ] 32 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0011_auto_20170422_1355.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.10.7 on 2017-04-22 12:55 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('catalogue', '0010_auto_20170420_0439'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AlterUniqueTogether( 16 | name='productimage', 17 | unique_together=set([]), 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0012_auto_20170609_1902.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.2 on 2017-06-09 18:02 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('catalogue', '0011_auto_20170422_1355'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AddField( 16 | model_name='productattributevalue', 17 | name='value_datetime', 18 | field=models.DateTimeField(blank=True, null=True, verbose_name='DateTime'), 19 | ), 20 | migrations.AlterField( 21 | model_name='productattribute', 22 | name='type', 23 | field=models.CharField(choices=[('text', 'Text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('richtext', 'Rich Text'), ('date', 'Date'), ('datetime', 'Datetime'), ('option', 'Option'), ('multi_option', 'Multi Option'), ('entity', 'Entity'), ('file', 'File'), ('image', 'Image')], default='text', max_length=20, verbose_name='Type'), 24 | ), 25 | ] 26 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0013_auto_20180214_1133.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.9 on 2018-02-14 11:33 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('catalogue', '0012_auto_20170609_1902'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AddField( 16 | model_name='category', 17 | name='description_az', 18 | field=models.TextField(blank=True, null=True, verbose_name='Description'), 19 | ), 20 | migrations.AddField( 21 | model_name='category', 22 | name='description_en', 23 | field=models.TextField(blank=True, null=True, verbose_name='Description'), 24 | ), 25 | migrations.AddField( 26 | model_name='category', 27 | name='description_ru', 28 | field=models.TextField(blank=True, null=True, verbose_name='Description'), 29 | ), 30 | migrations.AddField( 31 | model_name='category', 32 | name='name_az', 33 | field=models.CharField(db_index=True, max_length=255, null=True, verbose_name='Name'), 34 | ), 35 | migrations.AddField( 36 | model_name='category', 37 | name='name_en', 38 | field=models.CharField(db_index=True, max_length=255, null=True, verbose_name='Name'), 39 | ), 40 | migrations.AddField( 41 | model_name='category', 42 | name='name_ru', 43 | field=models.CharField(db_index=True, max_length=255, null=True, verbose_name='Name'), 44 | ), 45 | migrations.AddField( 46 | model_name='product', 47 | name='description_az', 48 | field=models.TextField(blank=True, null=True, verbose_name='Description'), 49 | ), 50 | migrations.AddField( 51 | model_name='product', 52 | name='description_en', 53 | field=models.TextField(blank=True, null=True, verbose_name='Description'), 54 | ), 55 | migrations.AddField( 56 | model_name='product', 57 | name='description_ru', 58 | field=models.TextField(blank=True, null=True, verbose_name='Description'), 59 | ), 60 | migrations.AddField( 61 | model_name='product', 62 | name='title_az', 63 | field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Title'), 64 | ), 65 | migrations.AddField( 66 | model_name='product', 67 | name='title_en', 68 | field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Title'), 69 | ), 70 | migrations.AddField( 71 | model_name='product', 72 | name='title_ru', 73 | field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Title'), 74 | ), 75 | migrations.AddField( 76 | model_name='productattribute', 77 | name='name_az', 78 | field=models.CharField(max_length=128, null=True, verbose_name='Name'), 79 | ), 80 | migrations.AddField( 81 | model_name='productattribute', 82 | name='name_en', 83 | field=models.CharField(max_length=128, null=True, verbose_name='Name'), 84 | ), 85 | migrations.AddField( 86 | model_name='productattribute', 87 | name='name_ru', 88 | field=models.CharField(max_length=128, null=True, verbose_name='Name'), 89 | ), 90 | ] 91 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/0014_product_best_seller.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.9 on 2018-04-17 15:14 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('catalogue', '0013_auto_20180214_1133'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AddField( 16 | model_name='product', 17 | name='best_seller', 18 | field=models.BooleanField(default=False), 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/oscar_apps/catalogue/migrations/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/models.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.catalogue.abstract_models import AbstractProduct 2 | from oscar.apps.partner.models import StockRecord 3 | from django.db import models 4 | import json 5 | 6 | 7 | class Product(AbstractProduct): 8 | best_seller = models.BooleanField(default=False) 9 | 10 | def get_variants(self): 11 | return Product.objects.filter(parent=self) 12 | 13 | def get_common_colors(self, type): 14 | _colors = [] 15 | for product in self.get_variants(): 16 | attrs = product.attribute_values.all() 17 | for item in attrs: 18 | # _colors.append(item.attribute.name) 19 | if item.attribute.code == type and not _colors.__contains__(item.value.option): 20 | _colors.append(item.value.option) 21 | return _colors 22 | 23 | def get_base_type(self): 24 | return self.get_common_colors('type') 25 | 26 | def get_child_images(self): 27 | result = [] 28 | for product in self.get_variants(): 29 | for attr in product.attribute_values.all(): 30 | if attr.attribute.code == 'type' or attr.attribute.code == 'color': 31 | pass 32 | else: 33 | obj = {} 34 | obj['product_id'] = product.id 35 | obj['image_url'] = attr.value_image.url 36 | result.append(obj) 37 | return result 38 | 39 | def get_product_variants(self): 40 | result = [] 41 | for product in self.get_variants(): 42 | resultObj = {} 43 | for attr in product.attribute_values.all(): 44 | if attr.attribute.code == 'type': 45 | resultObj['type'] = attr.value.option 46 | elif attr.attribute.code == 'color': 47 | resultObj['color'] = attr.value.option 48 | else: 49 | if hasattr(attr, 'value_image'): 50 | resultObj['picture_url'] = attr.value_image.url 51 | resultObj['product_id'] = product.id 52 | resultObj['title'] = product.get_title() 53 | try: 54 | record = StockRecord.objects.get(product=product) 55 | resultObj['price'] = float(record.price_excl_tax) 56 | except: 57 | resultObj['price'] = 0 58 | result.append(resultObj) 59 | return json.dumps(result) 60 | 61 | def get_first_color(self): 62 | _colors = [] 63 | first_obj = self.get_base_type()[0] 64 | for product in self.get_variants(): 65 | check = product.attribute_values.filter(value_option__option=first_obj) 66 | attrs = product.attribute_values.all() 67 | if check: 68 | for item in attrs: 69 | if item.attribute.code == 'color' and not _colors.__contains__(item.value.option): 70 | _colors.append(item.value.option) 71 | 72 | 73 | from oscar.apps.catalogue.models import * 74 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/catalogue/views.py: -------------------------------------------------------------------------------- 1 | # from oscar.apps.catalogue import views as catalogue_views 2 | # from oscar.apps.partner.strategy import Selector 3 | # from django.shortcuts import render 4 | # from django.http import JsonResponse 5 | # from bucket.options.debug import Logger 6 | # 7 | # mslog = Logger(file="test.log") 8 | # 9 | # 10 | # class ProductCategoryView(catalogue_views.ProductCategoryView): 11 | # ajax_template_name = 'catalogue/partials/money_range_product.html' 12 | # 13 | # def get(self, request, *args, **kwargs): 14 | # # Fetch the category; return 404 or redirect as needed 15 | # self.category = self.get_category() 16 | # mslog.debug(self.category) 17 | # potential_redirect = self.redirect_if_necessary( 18 | # request.path, self.category) 19 | # mslog.debug(potential_redirect) 20 | # if potential_redirect is not None: 21 | # return potential_redirect 22 | # 23 | # try: 24 | # self.search_handler = self.get_search_handler( 25 | # request.GET, request.get_full_path(), self.get_categories()) 26 | # mslog.debug(self.search_handler.get_queryset()) 27 | # except catalogue_views.InvalidPage: 28 | # catalogue_views.messages.error(request, catalogue_views._('The given page number was invalid.')) 29 | # return catalogue_views.redirect(self.category.get_absolute_url()) 30 | # if self.request.is_ajax(): 31 | # return render(self.request, self.ajax_template_name, {'product':self.search_handler.get_queryset()}) 32 | # return super(ProductCategoryView, self).get(request, *args, **kwargs) 33 | # 34 | # def handle_product_price_range(self, queryset, min, max): 35 | # selector = Selector() 36 | # strategy = selector.strategy() 37 | # pass 38 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/checkout/__init__.py: -------------------------------------------------------------------------------- 1 | default_app_config = 'oscar_apps.checkout.config.CheckoutConfig' 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/checkout/app.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.checkout import app as checkout_app 2 | # from .views import ShippingAddressView, UserAddressUpdateView, \ 3 | # IndexView, PaymentDetailsView, ThankYouView 4 | 5 | 6 | class CheckoutAppOscar(checkout_app.CheckoutApplication): 7 | pass 8 | # index_view = IndexView 9 | # shipping_address_view = ShippingAddressView 10 | # user_address_update_view = UserAddressUpdateView 11 | # payment_details_view = PaymentDetailsView 12 | # thankyou_view = ThankYouView 13 | 14 | 15 | application = CheckoutAppOscar() 16 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/checkout/config.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.checkout import config 2 | 3 | 4 | class CheckoutConfig(config.CheckoutConfig): 5 | name = 'oscar_apps.checkout' 6 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/checkout/forms.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.checkout import forms as checkout_forms 2 | from oscar.apps.order.models import ShippingAddress 3 | from oscar.apps.address import forms as current_address 4 | from django import forms 5 | 6 | 7 | class ShippingAddressForm(checkout_forms.ShippingAddressForm): 8 | class Meta: 9 | model = ShippingAddress 10 | fields = [ 11 | 'first_name', 'last_name', 12 | 'line1', 'line4', 'postcode', 'country', 13 | 'phone_number', 'notes', 14 | ] 15 | labels = { 16 | 'first_name': checkout_forms._("Ad"), 17 | 'last_name': checkout_forms._("Soyad"), 18 | 'line1': checkout_forms._("Ünvan"), 19 | 'line4': checkout_forms._("Şəhər"), 20 | 'postcode': checkout_forms._("Poçt index"), 21 | 'country': checkout_forms._("Ölkə"), 22 | 'phone_number': checkout_forms._("Telefon nömrəsi"), 23 | 'notes': checkout_forms._("Qeydlər"), 24 | } 25 | 26 | 27 | class UserAddressForm(current_address.UserAddressForm): 28 | class Meta: 29 | model = current_address.UserAddress 30 | fields = [ 31 | 'first_name', 'last_name', 32 | 'line1', 'line4', 'postcode', 'country', 33 | 'phone_number', 'notes', 34 | ] 35 | 36 | 37 | class GatewayForm(checkout_forms.GatewayForm): 38 | username = forms.EmailField(label=checkout_forms._("Mənim email addresim")) 39 | GUEST, NEW, EXISTING = 'anonymous', 'new', 'existing' 40 | CHOICES = ( 41 | (GUEST, checkout_forms._('Qeydiyyatsız email ilə ödəniş etmək')), 42 | (NEW, checkout_forms._('Yeni hesab yaratmaq')), 43 | (EXISTING, checkout_forms._('Hesaba daxil olmaq')) 44 | ) 45 | options = forms.ChoiceField(widget=forms.widgets.RadioSelect, 46 | choices=CHOICES, initial=GUEST) -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/checkout/models.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.checkout.models import * # noqa isort:skip 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/checkout/views.py: -------------------------------------------------------------------------------- 1 | # from django.conf import settings 2 | # from oscar.apps.checkout import views as checkout_views 3 | # from oscar.apps.payment import exceptions 4 | # from django.core.mail import send_mail 5 | # 6 | # from bucket.models import AdminEmails 7 | # from .forms import ShippingAddressForm, UserAddressForm, GatewayForm 8 | # 9 | # from pasha_payment.pashapay import PashaPay 10 | # from pasha_payment.utils import get_client_ip 11 | # 12 | # import logging 13 | # 14 | # # Get an instance of a logger 15 | # logr = logging.getLogger(__name__) 16 | # 17 | # 18 | # class ShippingAddressView(checkout_views.ShippingAddressView): 19 | # form_class = ShippingAddressForm 20 | # 21 | # 22 | # class UserAddressUpdateView(checkout_views.UserAddressUpdateView): 23 | # form_class = UserAddressForm 24 | # 25 | # 26 | # class IndexView(checkout_views.IndexView): 27 | # form_class = GatewayForm 28 | # 29 | # 30 | # # @method_decorator(csrf_exempt, name='dispatch') 31 | # class PaymentDetailsView(checkout_views.PaymentDetailsView): 32 | # preview = True 33 | # 34 | # def handle_payment(self, order_number, total_incl_tax, **kwargs): 35 | # # Payment requires a redirect so we raise a RedirectRequired exception 36 | # # and oscar's checkout flow will handle the rest. 37 | # payment = PashaPay() 38 | # url = payment.redirect_to_pay( 39 | # amount=total_incl_tax.incl_tax, 40 | # description='One-off bill for order #%s' % order_number, 41 | # client_ip=get_client_ip(self.request), 42 | # ) 43 | # self.add_payment_event('pre-auth', total_incl_tax.incl_tax) 44 | # 45 | # raise exceptions.RedirectRequired(url) 46 | # 47 | # 48 | # # ========= 49 | # # Thank you 50 | # # ========= 51 | # 52 | # 53 | # class ThankYouView(checkout_views.ThankYouView): 54 | # 55 | # def get_context_data(self, *args, **kwargs): 56 | # ctx = super(ThankYouView, self).get_context_data(*args, **kwargs) 57 | # # Remember whether this view has been loaded. 58 | # # Only send tracking information on the first load. 59 | # self.send_message_to_admin(ctx['order']) 60 | # key = 'order_{}_thankyou_viewed'.format(ctx['order'].pk) 61 | # if not self.request.session.get(key, False): 62 | # self.request.session[key] = True 63 | # ctx['send_analytics_event'] = True 64 | # else: 65 | # ctx['send_analytics_event'] = False 66 | # 67 | # return ctx 68 | # 69 | # def send_message_to_admin(self, order): 70 | # emails = AdminEmails.objects.filter(status=True) 71 | # message = "{} nömrəli sifarışiniz var. Qiyməti: {} Link: {}".format( 72 | # order.number, 73 | # order.total_incl_tax, 74 | # "https://" + self.request.get_host() + "/ru/dashboard/orders/%s/" % order.number 75 | # ) 76 | # if emails.last(): 77 | # for email in emails: 78 | # if email.status: 79 | # send_mail("{} nömrəli yeni sifarişiniz var".format(order.number), 80 | # message, 81 | # settings.EMAIL_HOST_USER, 82 | # [email.email] 83 | # ) 84 | # return "Messages successfuly send" 85 | # 86 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/__init__.py: -------------------------------------------------------------------------------- 1 | default_app_config = 'oscar_apps.customer.config.CustomerConfig' 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/admin.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.customer.admin import * # noqa 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/app.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.customer import app as customer_app 2 | from .views import CustomerLoginView, AddressCreateView, AddressUpdateView, \ 3 | AnonymousOrderDetailView 4 | 5 | 6 | class CustomerOscarApplication(customer_app.CustomerApplication): 7 | login_view = CustomerLoginView 8 | address_create_view = AddressCreateView 9 | address_update_view = AddressUpdateView 10 | anon_order_detail_view = AnonymousOrderDetailView 11 | 12 | 13 | application = CustomerOscarApplication() 14 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/config.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.customer import config 2 | 3 | 4 | class CustomerConfig(config.CustomerConfig): 5 | name = 'oscar_apps.customer' 6 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/forms.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.customer import forms as customer_form 2 | from oscar.apps.address import forms as address_form 3 | 4 | 5 | class UserAddressForm(address_form.UserAddressForm): 6 | class Meta: 7 | model = address_form.UserAddress 8 | fields = [ 9 | 'first_name', 'last_name', 10 | 'line1', 'line4', 'postcode', 'country', 11 | 'phone_number', 'notes', 12 | ] 13 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | import oscar.models.fields.autoslugfield 6 | from django.conf import settings 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | ('catalogue', '0001_initial'), 13 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='CommunicationEventType', 19 | fields=[ 20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('code', oscar.models.fields.autoslugfield.AutoSlugField(populate_from='name', unique=True, verbose_name='Code', editable=False, separator='_', max_length=128, help_text='Code used for looking up this event programmatically', blank=True)), 22 | ('name', models.CharField(verbose_name='Name', max_length=255, help_text='This is just used for organisational purposes')), 23 | ('category', models.CharField(default='Order related', max_length=255, verbose_name='Category', choices=[('Order related', 'Order related'), ('User related', 'User related')])), 24 | ('email_subject_template', models.CharField(verbose_name='Email Subject Template', max_length=255, blank=True, null=True)), 25 | ('email_body_template', models.TextField(blank=True, verbose_name='Email Body Template', null=True)), 26 | ('email_body_html_template', models.TextField(verbose_name='Email Body HTML Template', blank=True, help_text='HTML template', null=True)), 27 | ('sms_template', models.CharField(verbose_name='SMS Template', max_length=170, help_text='SMS template', blank=True, null=True)), 28 | ('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Date Created')), 29 | ('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date Updated')), 30 | ], 31 | options={ 32 | 'verbose_name_plural': 'Communication event types', 33 | 'verbose_name': 'Communication event type', 34 | 'abstract': False, 35 | }, 36 | bases=(models.Model,), 37 | ), 38 | migrations.CreateModel( 39 | name='Email', 40 | fields=[ 41 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 42 | ('subject', models.TextField(max_length=255, verbose_name='Subject')), 43 | ('body_text', models.TextField(verbose_name='Body Text')), 44 | ('body_html', models.TextField(verbose_name='Body HTML', blank=True)), 45 | ('date_sent', models.DateTimeField(auto_now_add=True, verbose_name='Date Sent')), 46 | ('user', models.ForeignKey(verbose_name='User', related_name='emails', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), 47 | ], 48 | options={ 49 | 'verbose_name_plural': 'Emails', 50 | 'verbose_name': 'Email', 51 | 'abstract': False, 52 | }, 53 | bases=(models.Model,), 54 | ), 55 | migrations.CreateModel( 56 | name='Notification', 57 | fields=[ 58 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 59 | ('subject', models.CharField(max_length=255)), 60 | ('body', models.TextField()), 61 | ('category', models.CharField(max_length=255, blank=True)), 62 | ('location', models.CharField(default='Inbox', max_length=32, choices=[('Inbox', 'Inbox'), ('Archive', 'Archive')])), 63 | ('date_sent', models.DateTimeField(auto_now_add=True)), 64 | ('date_read', models.DateTimeField(blank=True, null=True)), 65 | ('recipient', models.ForeignKey(related_name='notifications', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), 66 | ('sender', models.ForeignKey(to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE)), 67 | ], 68 | options={ 69 | 'ordering': ('-date_sent',), 70 | 'verbose_name_plural': 'Notifications', 71 | 'verbose_name': 'Notification', 72 | 'abstract': False, 73 | }, 74 | bases=(models.Model,), 75 | ), 76 | migrations.CreateModel( 77 | name='ProductAlert', 78 | fields=[ 79 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 80 | ('email', models.EmailField(max_length=75, db_index=True, verbose_name='Email', blank=True)), 81 | ('key', models.CharField(max_length=128, db_index=True, verbose_name='Key', blank=True)), 82 | ('status', models.CharField(default='Active', max_length=20, verbose_name='Status', choices=[('Unconfirmed', 'Not yet confirmed'), ('Active', 'Active'), ('Cancelled', 'Cancelled'), ('Closed', 'Closed')])), 83 | ('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Date created')), 84 | ('date_confirmed', models.DateTimeField(blank=True, verbose_name='Date confirmed', null=True)), 85 | ('date_cancelled', models.DateTimeField(blank=True, verbose_name='Date cancelled', null=True)), 86 | ('date_closed', models.DateTimeField(blank=True, verbose_name='Date closed', null=True)), 87 | ('product', models.ForeignKey(to='catalogue.Product', on_delete=models.CASCADE)), 88 | ('user', models.ForeignKey(null=True, verbose_name='User', related_name='alerts', to=settings.AUTH_USER_MODEL, blank=True, on_delete=models.CASCADE)), 89 | ], 90 | options={ 91 | 'verbose_name_plural': 'Product alerts', 92 | 'verbose_name': 'Product alert', 93 | 'abstract': False, 94 | }, 95 | bases=(models.Model,), 96 | ), 97 | ] 98 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/migrations/0002_auto_20150807_1725.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | import oscar.models.fields.autoslugfield 6 | import django.core.validators 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | ('customer', '0001_initial'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AlterField( 17 | model_name='communicationeventtype', 18 | name='code', 19 | field=oscar.models.fields.autoslugfield.AutoSlugField(populate_from='name', validators=[django.core.validators.RegexValidator(regex=r'^[a-zA-Z_][0-9a-zA-Z_]*$', message="Code can only contain the letters a-z, A-Z, digits, and underscores, and can't start with a digit.")], editable=False, max_length=128, separator='_', blank=True, help_text='Code used for looking up this event programmatically', unique=True, verbose_name='Code'), 20 | preserve_default=True, 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/migrations/0003_update_email_length.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9.7 on 2016-07-13 08:44 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('customer', '0002_auto_20150807_1725'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AlterField( 16 | model_name='productalert', 17 | name='email', 18 | field=models.EmailField(blank=True, db_index=True, max_length=254, verbose_name='Email'), 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/migrations/0004_email_save.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.10.7 on 2017-04-13 17:53 3 | from __future__ import unicode_literals 4 | 5 | from django.conf import settings 6 | from django.db import migrations, models 7 | import django.db.models.deletion 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | dependencies = [ 13 | ('customer', '0003_update_email_length'), 14 | ] 15 | 16 | operations = [ 17 | migrations.AddField( 18 | model_name='email', 19 | name='email', 20 | field=models.EmailField(blank=True, max_length=254, null=True, verbose_name='Email Address'), 21 | ), 22 | migrations.AlterField( 23 | model_name='email', 24 | name='user', 25 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='emails', to=settings.AUTH_USER_MODEL, verbose_name='User'), 26 | ), 27 | ] 28 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/oscar_apps/customer/migrations/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/models.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.customer.models import * # noqa isort:skip 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/customer/views.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.customer import views as customer_views 2 | from oscar.apps.wishlists.models import WishList 3 | from .forms import UserAddressForm 4 | 5 | 6 | class CustomerLoginView(customer_views.AccountAuthView): 7 | def get_registration_success_message(self, form): 8 | user = form.save(commit=False) 9 | WishList.objects.create( 10 | owner=user, 11 | name="Arzu siyahısı", 12 | visibility='Public' 13 | ) 14 | return customer_views._("Qeydiyyat üçün təşəkkürlər") 15 | 16 | 17 | class AddressCreateView(customer_views.AddressCreateView): 18 | form_class = UserAddressForm 19 | 20 | 21 | class AddressUpdateView(customer_views.AddressUpdateView): 22 | form_class = UserAddressForm 23 | 24 | 25 | class AnonymousOrderDetailView(customer_views.AnonymousOrderDetailView): 26 | pass -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/__init__.py: -------------------------------------------------------------------------------- 1 | default_app_config = 'oscar_apps.dashboard.config.DashboardConfig' 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/catalogue/__init__.py: -------------------------------------------------------------------------------- 1 | default_app_config = 'oscar_apps.dashboard.catalogue.config.CatalogueDashboardConfig' 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/catalogue/app.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.catalogue import app as catalogue_admin_app 2 | from .views import ProductClassCreateView, ProductClassUpdateView, ProductCreateUpdateView, \ 3 | CategoryCreateView, CategoryUpdateView 4 | 5 | 6 | class CatalogueAdminApp(catalogue_admin_app.CatalogueApplication): 7 | product_class_create_view = ProductClassCreateView 8 | product_class_update_view = ProductClassUpdateView 9 | product_createupdate_view = ProductCreateUpdateView 10 | category_create_view = CategoryCreateView 11 | category_update_view = CategoryUpdateView 12 | 13 | 14 | application = CatalogueAdminApp() 15 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/catalogue/config.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.catalogue import config 2 | 3 | 4 | class CatalogueDashboardConfig(config.CatalogueDashboardConfig): 5 | name = 'oscar_apps.dashboard.catalogue' 6 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/catalogue/forms.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.catalogue import forms as catalogue_admin_forms 2 | from ckeditor_uploader.widgets import CKEditorUploadingWidget 3 | 4 | 5 | class ProductAttributesForm(catalogue_admin_forms.ProductAttributesForm): 6 | class Meta: 7 | model = catalogue_admin_forms.ProductAttribute 8 | fields = ["name_az", "name_en", "name_ru", "code", "type", "option_group", "required"] 9 | 10 | 11 | class ProductForm(catalogue_admin_forms.ProductForm): 12 | class Meta: 13 | model = catalogue_admin_forms.Product 14 | fields = [ 15 | 'title_az', 'title_en', 'title_ru', 'upc', 'description_az', 'description_en', 'description_ru', 16 | 'is_discountable', 'best_seller', 'structure'] 17 | widgets = { 18 | 'structure': catalogue_admin_forms.forms.Select(), 19 | 'description_az': CKEditorUploadingWidget(), 20 | 'description_en': CKEditorUploadingWidget(), 21 | 'description_ru': CKEditorUploadingWidget() 22 | } 23 | 24 | 25 | CategoryForm = catalogue_admin_forms.movenodeform_factory( 26 | catalogue_admin_forms.Category, 27 | fields=['name_az', 'name_en', 'name_ru', 'description_az', 28 | 'description_en', 'description_ru', 'image'], 29 | widgets={ 30 | 'description_az': CKEditorUploadingWidget(), 31 | 'description_en': CKEditorUploadingWidget(), 32 | 'description_ru': CKEditorUploadingWidget() 33 | } 34 | ) 35 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/catalogue/formsets.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.catalogue import formsets as catalogue_admin_formset 2 | from .forms import ProductAttributesForm 3 | 4 | ProductAttributesFormSet = catalogue_admin_formset.inlineformset_factory(catalogue_admin_formset.ProductClass, 5 | catalogue_admin_formset.ProductAttribute, 6 | form=ProductAttributesForm, 7 | extra=15) -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/catalogue/models.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.catalogue.models import * # noqa isort:skip 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/catalogue/views.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.catalogue import views as catalogue_admin_views 2 | from .formsets import ProductAttributesFormSet 3 | from .forms import ProductForm, CategoryForm 4 | 5 | 6 | class ProductClassCreateView(catalogue_admin_views.ProductClassCreateView): 7 | product_attributes_formset = ProductAttributesFormSet 8 | 9 | 10 | class ProductClassUpdateView(catalogue_admin_views.ProductClassUpdateView): 11 | product_attributes_formset = ProductAttributesFormSet 12 | 13 | 14 | class ProductCreateUpdateView(catalogue_admin_views.ProductCreateUpdateView): 15 | form_class = ProductForm 16 | 17 | 18 | class CategoryCreateView(catalogue_admin_views.CategoryCreateView): 19 | form_class = CategoryForm 20 | 21 | 22 | class CategoryUpdateView(catalogue_admin_views.CategoryUpdateView): 23 | form_class = CategoryForm 24 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/pages/__init__.py: -------------------------------------------------------------------------------- 1 | default_app_config = 'oscar_apps.dashboard.pages.config.PagesDashboardConfig' 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/pages/app.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.pages import app as pages_app_admin 2 | from .views import PageUpdateView, PageCreateView 3 | 4 | 5 | class PagesApplication(pages_app_admin.FlatPageManagementApplication): 6 | create_view = PageCreateView 7 | update_view = PageUpdateView 8 | 9 | 10 | application = PagesApplication() 11 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/pages/config.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.pages import config 2 | 3 | 4 | class PagesDashboardConfig(config.PagesDashboardConfig): 5 | name = 'oscar_apps.dashboard.pages' 6 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/pages/forms.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.pages import forms as page_forms_admin 2 | from ckeditor_uploader.widgets import CKEditorUploadingWidget 3 | 4 | 5 | class PageUpdateForm(page_forms_admin.PageUpdateForm): 6 | class Meta: 7 | model = page_forms_admin.FlatPage 8 | fields = ('title_az', 'title_en', 'title_ru', 9 | 'url', 'content_az', 'content_en', 10 | 'content_ru') 11 | widgets = { 12 | 'content_az': CKEditorUploadingWidget(), 13 | 'content_en': CKEditorUploadingWidget(), 14 | 'content_ru': CKEditorUploadingWidget() 15 | } 16 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/dashboard/pages/views.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.dashboard.pages import views as page_views_admin 2 | from .forms import PageUpdateForm 3 | 4 | 5 | class PageCreateView(page_views_admin.PageCreateView): 6 | form_class = PageUpdateForm 7 | 8 | 9 | class PageUpdateView(page_views_admin.PageUpdateView): 10 | form_class = PageUpdateForm 11 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/promotions/__init__.py: -------------------------------------------------------------------------------- 1 | default_app_config = 'oscar_apps.promotions.config.PromotionsConfig' 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/promotions/admin.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.promotions.admin import * # noqa 2 | 3 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/promotions/app.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.promotions import app as promotions_app 2 | from .views import IndexView 3 | 4 | 5 | class PromotionsApp(promotions_app.PromotionsApplication): 6 | name = 'promotions' 7 | 8 | home_view = IndexView 9 | 10 | 11 | application = PromotionsApp() -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/promotions/config.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.promotions import config 2 | 3 | 4 | class PromotionsConfig(config.PromotionsConfig): 5 | name = 'oscar_apps.promotions' 6 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/promotions/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | import oscar.models.fields 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('catalogue', '0001_initial'), 12 | ('contenttypes', '0001_initial'), 13 | ] 14 | 15 | operations = [ 16 | migrations.CreateModel( 17 | name='AutomaticProductList', 18 | fields=[ 19 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 20 | ('name', models.CharField(max_length=255, verbose_name='Title')), 21 | ('description', models.TextField(verbose_name='Description', blank=True)), 22 | ('link_url', oscar.models.fields.ExtendedURLField(verbose_name='Link URL', blank=True)), 23 | ('link_text', models.CharField(max_length=255, verbose_name='Link text', blank=True)), 24 | ('date_created', models.DateTimeField(auto_now_add=True)), 25 | ('method', models.CharField(max_length=128, verbose_name='Method', choices=[('Bestselling', 'Bestselling products'), ('RecentlyAdded', 'Recently added products')])), 26 | ('num_products', models.PositiveSmallIntegerField(default=4, verbose_name='Number of Products')), 27 | ], 28 | options={ 29 | 'verbose_name_plural': 'Automatic product lists', 30 | 'verbose_name': 'Automatic product list', 31 | }, 32 | bases=(models.Model,), 33 | ), 34 | migrations.CreateModel( 35 | name='HandPickedProductList', 36 | fields=[ 37 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 38 | ('name', models.CharField(max_length=255, verbose_name='Title')), 39 | ('description', models.TextField(verbose_name='Description', blank=True)), 40 | ('link_url', oscar.models.fields.ExtendedURLField(verbose_name='Link URL', blank=True)), 41 | ('link_text', models.CharField(max_length=255, verbose_name='Link text', blank=True)), 42 | ('date_created', models.DateTimeField(auto_now_add=True)), 43 | ], 44 | options={ 45 | 'verbose_name_plural': 'Hand Picked Product Lists', 46 | 'verbose_name': 'Hand Picked Product List', 47 | }, 48 | bases=(models.Model,), 49 | ), 50 | migrations.CreateModel( 51 | name='Image', 52 | fields=[ 53 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 54 | ('name', models.CharField(max_length=128, verbose_name='Name')), 55 | ('link_url', oscar.models.fields.ExtendedURLField(verbose_name='Link URL', help_text='This is where this promotion links to', blank=True)), 56 | ('image', models.ImageField(upload_to='images/promotions/', max_length=255, verbose_name='Image')), 57 | ('date_created', models.DateTimeField(auto_now_add=True)), 58 | ], 59 | options={ 60 | 'verbose_name_plural': 'Image', 61 | 'verbose_name': 'Image', 62 | }, 63 | bases=(models.Model,), 64 | ), 65 | migrations.CreateModel( 66 | name='KeywordPromotion', 67 | fields=[ 68 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 69 | ('object_id', models.PositiveIntegerField()), 70 | ('position', models.CharField(verbose_name='Position', max_length=100, help_text='Position on page')), 71 | ('display_order', models.PositiveIntegerField(default=0, verbose_name='Display Order')), 72 | ('clicks', models.PositiveIntegerField(default=0, verbose_name='Clicks')), 73 | ('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Date Created')), 74 | ('keyword', models.CharField(max_length=200, verbose_name='Keyword')), 75 | ('filter', models.CharField(max_length=200, verbose_name='Filter', blank=True)), 76 | ('content_type', models.ForeignKey(to='contenttypes.ContentType', on_delete=models.CASCADE)), 77 | ], 78 | options={ 79 | 'ordering': ['-clicks'], 80 | 'verbose_name_plural': 'Keyword Promotions', 81 | 'verbose_name': 'Keyword Promotion', 82 | 'abstract': False, 83 | }, 84 | bases=(models.Model,), 85 | ), 86 | migrations.CreateModel( 87 | name='MultiImage', 88 | fields=[ 89 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 90 | ('name', models.CharField(max_length=128, verbose_name='Name')), 91 | ('date_created', models.DateTimeField(auto_now_add=True)), 92 | ('images', models.ManyToManyField(blank=True, help_text='Choose the Image content blocks that this block will use. (You may need to create some first).', to='promotions.Image', null=True)), 93 | ], 94 | options={ 95 | 'verbose_name_plural': 'Multi Images', 96 | 'verbose_name': 'Multi Image', 97 | }, 98 | bases=(models.Model,), 99 | ), 100 | migrations.CreateModel( 101 | name='OrderedProduct', 102 | fields=[ 103 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 104 | ('display_order', models.PositiveIntegerField(default=0, verbose_name='Display Order')), 105 | ], 106 | options={ 107 | 'ordering': ('display_order',), 108 | 'verbose_name_plural': 'Ordered product', 109 | 'verbose_name': 'Ordered product', 110 | }, 111 | bases=(models.Model,), 112 | ), 113 | migrations.CreateModel( 114 | name='OrderedProductList', 115 | fields=[ 116 | ('handpickedproductlist_ptr', models.OneToOneField(parent_link=True, 117 | serialize=False, 118 | auto_created=True, 119 | primary_key=True, 120 | to='promotions.HandPickedProductList', 121 | on_delete=models.CASCADE)), 122 | ('display_order', models.PositiveIntegerField(default=0, verbose_name='Display Order')), 123 | ], 124 | options={ 125 | 'ordering': ('display_order',), 126 | 'verbose_name_plural': 'Ordered Product Lists', 127 | 'verbose_name': 'Ordered Product List', 128 | }, 129 | bases=('promotions.handpickedproductlist',), 130 | ), 131 | migrations.CreateModel( 132 | name='PagePromotion', 133 | fields=[ 134 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 135 | ('object_id', models.PositiveIntegerField()), 136 | ('position', models.CharField(verbose_name='Position', max_length=100, help_text='Position on page')), 137 | ('display_order', models.PositiveIntegerField(default=0, verbose_name='Display Order')), 138 | ('clicks', models.PositiveIntegerField(default=0, verbose_name='Clicks')), 139 | ('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Date Created')), 140 | ('page_url', oscar.models.fields.ExtendedURLField(max_length=128, db_index=True, verbose_name='Page URL')), 141 | ('content_type', models.ForeignKey(to='contenttypes.ContentType', on_delete=models.CASCADE)), 142 | ], 143 | options={ 144 | 'ordering': ['-clicks'], 145 | 'verbose_name_plural': 'Page Promotions', 146 | 'verbose_name': 'Page Promotion', 147 | 'abstract': False, 148 | }, 149 | bases=(models.Model,), 150 | ), 151 | migrations.CreateModel( 152 | name='RawHTML', 153 | fields=[ 154 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 155 | ('name', models.CharField(max_length=128, verbose_name='Name')), 156 | ('display_type', models.CharField(verbose_name='Display type', max_length=128, help_text='This can be used to have different types of HTML blocks (eg different widths)', blank=True)), 157 | ('body', models.TextField(verbose_name='HTML')), 158 | ('date_created', models.DateTimeField(auto_now_add=True)), 159 | ], 160 | options={ 161 | 'verbose_name_plural': 'Raw HTML', 162 | 'verbose_name': 'Raw HTML', 163 | }, 164 | bases=(models.Model,), 165 | ), 166 | migrations.CreateModel( 167 | name='SingleProduct', 168 | fields=[ 169 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 170 | ('name', models.CharField(max_length=128, verbose_name='Name')), 171 | ('description', models.TextField(verbose_name='Description', blank=True)), 172 | ('date_created', models.DateTimeField(auto_now_add=True)), 173 | ('product', models.ForeignKey(to='catalogue.Product', on_delete=models.CASCADE)), 174 | ], 175 | options={ 176 | 'verbose_name_plural': 'Single product', 177 | 'verbose_name': 'Single product', 178 | }, 179 | bases=(models.Model,), 180 | ), 181 | migrations.CreateModel( 182 | name='TabbedBlock', 183 | fields=[ 184 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 185 | ('name', models.CharField(max_length=255, verbose_name='Title')), 186 | ('date_created', models.DateTimeField(auto_now_add=True, verbose_name='Date Created')), 187 | ], 188 | options={ 189 | 'verbose_name_plural': 'Tabbed Blocks', 190 | 'verbose_name': 'Tabbed Block', 191 | }, 192 | bases=(models.Model,), 193 | ), 194 | migrations.AddField( 195 | model_name='orderedproductlist', 196 | name='tabbed_block', 197 | field=models.ForeignKey(verbose_name='Tabbed Block', related_name='tabs', to='promotions.TabbedBlock', on_delete=models.CASCADE), 198 | preserve_default=True, 199 | ), 200 | migrations.AddField( 201 | model_name='orderedproduct', 202 | name='list', 203 | field=models.ForeignKey(verbose_name='List', to='promotions.HandPickedProductList', on_delete=models.CASCADE), 204 | preserve_default=True, 205 | ), 206 | migrations.AddField( 207 | model_name='orderedproduct', 208 | name='product', 209 | field=models.ForeignKey(verbose_name='Product', to='catalogue.Product', on_delete=models.CASCADE), 210 | preserve_default=True, 211 | ), 212 | migrations.AlterUniqueTogether( 213 | name='orderedproduct', 214 | unique_together=set([('list', 'product')]), 215 | ), 216 | migrations.AddField( 217 | model_name='handpickedproductlist', 218 | name='products', 219 | field=models.ManyToManyField(through='promotions.OrderedProduct', blank=True, verbose_name='Products', to='catalogue.Product', null=True), 220 | preserve_default=True, 221 | ), 222 | ] 223 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/promotions/migrations/0002_auto_20150604_1450.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('promotions', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AlterField( 15 | model_name='handpickedproductlist', 16 | name='products', 17 | field=models.ManyToManyField(to='catalogue.Product', verbose_name='Products', through='promotions.OrderedProduct', blank=True), 18 | ), 19 | migrations.AlterField( 20 | model_name='multiimage', 21 | name='images', 22 | field=models.ManyToManyField(help_text='Choose the Image content blocks that this block will use. (You may need to create some first).', to='promotions.Image', blank=True), 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/promotions/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/munisisazade/create-django-app/f62395af2adaacacc4d3a3857c6570c9647d13a1/tlp/django_app/oscar_apps/promotions/migrations/__init__.py -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/promotions/models.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.promotions.models import * # noqa isort:skip 2 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_apps/promotions/views.py: -------------------------------------------------------------------------------- 1 | from oscar.apps.promotions import views as promotions_views 2 | from oscar_apps.catalogue.models import Product 3 | from django.db.models import Q 4 | # from bucket.models import BaseSlider, InstagramImage, Composition 5 | # from bucket.tasks import instagram_task 6 | 7 | 8 | class IndexView(promotions_views.HomeView): 9 | template_name = 'promotions/home.html' 10 | 11 | def get_context_data(self, **kwargs): 12 | context = super(IndexView, self).get_context_data(**kwargs) 13 | # context['sliders'] = BaseSlider.objects.filter(status=True) 14 | # context['new_products'] = Product.objects.filter(~Q(structure="child"))[:16] 15 | # context['compositions'] = Composition.objects.filter(status=True)[:2] 16 | # context['best_seller_products'] = Product.objects.filter(~Q(structure="child"), Q(best_seller=True)) 17 | # context['instagram_images'] = InstagramImage.objects.all().order_by('-id')[:6] 18 | # context['instagram_cover'] = InstagramImage.objects.all().order_by('-id')[6:7] 19 | # instagram_task.delay() 20 | return context -------------------------------------------------------------------------------- /tlp/django_app/oscar_settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for bouquet project. 3 | 4 | Generated by 'django-admin startproject' using Django 1.11. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.11/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/1.11/ref/settings/ 11 | """ 12 | 13 | import os 14 | from django.utils.translation import ugettext_lazy as _ 15 | 16 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 17 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 18 | 19 | # Oscar defaults settings import all module 20 | from oscar.defaults import * 21 | 22 | # Quick-start development settings - unsuitable for production 23 | # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ 24 | 25 | # SECURITY WARNING: keep the secret key used in production secret! 26 | SECRET_KEY = "#{SECRET_KEY}" 27 | # SECURITY WARNING: don't run with debug turned on in production! 28 | DEBUG = False if os.environ.get('DEBUG', False) == "False" else True 29 | PROD = not DEBUG 30 | 31 | ALLOWED_HOSTS = ['*'] if PROD else ['*'] 32 | 33 | EMAIL_HOST = 'smtp.****' 34 | EMAIL_HOST_USER = 'noreply@email.net' 35 | EMAIL_HOST_PASSWORD = 'mnbvcxzas' 36 | EMAIL_PORT = 465 37 | EMAIL_USE_TLS = True 38 | EMAIL_USE_SSL = False 39 | DEFAULT_FROM_EMAIL = "#{PROJ_NAME} <%s>" % EMAIL_HOST_USER 40 | 41 | OSCAR_SEND_REGISTRATION_EMAIL = True 42 | OSCAR_FROM_EMAIL = EMAIL_HOST_USER 43 | 44 | # Instagram Page Url 45 | # INSTAGRAM_PAGE_URL = "https://www.instagram.com/bouquet.aze/" 46 | 47 | # Application definition 48 | # Locale translation files here 49 | LOCALE_PATHS = ( 50 | os.path.join(BASE_DIR, 'locale'), 51 | ) 52 | 53 | THUMBNAIL_QUALITY = 100 54 | 55 | # Default login required 56 | LOGIN_URL = '/accounts/login/' 57 | # Application definition 58 | # Oscar intalled apps register 59 | OSCAR_SHOP_NAME = '#{PROJ_NAME}' 60 | OSCAR_SHOP_TAGLINE = _('#{PROJ_NAME}') 61 | from oscar import get_core_apps 62 | 63 | INSTALLED_APPS = [ 64 | 'modeltranslation', 65 | 'django.contrib.admin', 66 | 'django.contrib.auth', 67 | 'django.contrib.contenttypes', 68 | 'django.contrib.sessions', 69 | 'django.contrib.messages', 70 | 'django.contrib.staticfiles', 71 | 'django.contrib.sites', 72 | 'django.contrib.flatpages', 73 | 'celery', # Don't forget to add celery 74 | 'django_celery_results', # celery result 75 | 'django_celery_beat', 76 | # 'rosetta', # for translation 77 | 'ckeditor', 78 | 'ckeditor_uploader', 79 | 'widget_tweaks', 80 | '#{APP_NAME}.apps.#{DJANGO_UP_APP_NAME}Config', 81 | 82 | ] + get_core_apps() # + get_core_apps(['oscar_apps.dashboard.pages', 83 | # 'oscar_apps.dashboard.catalogue', 84 | # 'oscar_apps.checkout', 85 | # 'oscar_apps.customer', 86 | # 'oscar_apps.catalogue', 87 | # 'oscar_apps.basket', 88 | # 'oscar_apps.promotions']) 89 | 90 | # Oscar shopping configuration 91 | OSCAR_ALLOW_ANON_CHECKOUT = True 92 | OSCAR_INITIAL_ORDER_STATUS = 'Pending' 93 | OSCAR_INITIAL_LINE_STATUS = 'Pending' 94 | OSCAR_ORDER_STATUS_PIPELINE = { 95 | 'Pending': ('Being processed', 'Cancelled',), 96 | 'Being processed': ('Processed', 'Cancelled',), 97 | 'Cancelled': (), 98 | } 99 | 100 | OSCAR_REQUIRED_ADDRESS_FIELDS = ('phone_number', 'line1') 101 | 102 | OSCAR_SEARCH_FACETS = { 103 | 'fields': OrderedDict([ 104 | ('product_class', {'name': _('Type'), 'field': 'product_class'}), 105 | ('rating', {'name': _('Rating'), 'field': 'rating'}), 106 | ]), 107 | 'queries': OrderedDict([ 108 | ('price_range', 109 | { 110 | 'name': _('Price range'), 111 | 'field': 'price', 112 | 'queries': [ 113 | # This is a list of (name, query) tuples where the name will 114 | # be displayed on the front-end. 115 | (_('0 to 20'), u'[0 TO 20]'), 116 | (_('20 to 40'), u'[20 TO 40]'), 117 | (_('40 to 60'), u'[40 TO 60]'), 118 | (_('60+'), u'[60 TO *]'), 119 | ] 120 | }), 121 | ]), 122 | } 123 | 124 | HAYSTACK_CONNECTIONS = { 125 | 'default': { 126 | 'ENGINE': 'haystack.backends.elasticsearch2_backend.Elasticsearch2SearchEngine', 127 | 'URL': 'http://127.0.0.1:9200/', 128 | 'INDEX_NAME': 'haystack', 129 | }, 130 | } 131 | 132 | CELERY_DATABASE_STORE = True 133 | 134 | CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' 135 | CKEDITOR_UPLOAD_PATH = "uploads/" 136 | 137 | CKEDITOR_CONFIGS = { 138 | 'default': { 139 | 'skin': 'moono', 140 | # 'skin': 'office2013', 141 | 'toolbar_Basic': [ 142 | ['Source', '-', 'Bold', 'Italic'] 143 | ], 144 | 'toolbar_YouCustomToolbarConfig': [ 145 | {'name': 'document', 'items': ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates']}, 146 | {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']}, 147 | {'name': 'editing', 'items': ['Find', 'Replace', '-', 'SelectAll']}, 148 | {'name': 'forms', 149 | 'items': ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 150 | 'HiddenField']}, 151 | '/', 152 | {'name': 'basicstyles', 153 | 'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']}, 154 | {'name': 'paragraph', 155 | 'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 156 | 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 157 | 'Language']}, 158 | {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']}, 159 | {'name': 'insert', 160 | 'items': ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe']}, 161 | '/', 162 | {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']}, 163 | {'name': 'colors', 'items': ['TextColor', 'BGColor']}, 164 | {'name': 'tools', 'items': ['Maximize', 'ShowBlocks']}, 165 | {'name': 'about', 'items': ['About']}, 166 | '/', # put this to force next toolbar on new line 167 | {'name': 'youcustomtools', 'items': [ 168 | # put the name of your editor.ui.addButton here 169 | 'Preview', 170 | 'Maximize', 171 | ]}, 172 | ], 173 | 'toolbar': 'YouCustomToolbarConfig', # put selected toolbar config here 174 | # 'toolbarGroups': [{ 'name': 'document', 'groups': [ 'mode', 'document', 'doctools' ] }], 175 | # 'height': 291, 176 | # 'width': '100%', 177 | # 'filebrowserWindowHeight': 725, 178 | # 'filebrowserWindowWidth': 940, 179 | # 'toolbarCanCollapse': True, 180 | # 'mathJaxLib': '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML', 181 | 'tabSpaces': 4, 182 | 'extraPlugins': ','.join( 183 | [ 184 | # you extra plugins here 185 | 'div', 186 | 'autolink', 187 | 'autoembed', 188 | 'embedsemantic', 189 | 'autogrow', 190 | # 'devtools', 191 | 'widget', 192 | 'lineutils', 193 | 'clipboard', 194 | 'dialog', 195 | 'dialogui', 196 | 'elementspath' 197 | ]), 198 | } 199 | } 200 | 201 | MIDDLEWARE = [ 202 | 'django.middleware.security.SecurityMiddleware', 203 | '#{PROJ_NAME}.middleware.force_default_middleware.force_default_language_middleware', 204 | 'django.middleware.locale.LocaleMiddleware', 205 | 'django.contrib.sessions.middleware.SessionMiddleware', 206 | 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', 207 | 'django.middleware.common.CommonMiddleware', 208 | 'django.middleware.csrf.CsrfViewMiddleware', 209 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 210 | 'django.contrib.messages.middleware.MessageMiddleware', 211 | # Oscar middleware apps 212 | 'oscar.apps.basket.middleware.BasketMiddleware', 213 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 214 | ] 215 | 216 | ROOT_URLCONF = '#{PROJ_NAME}.urls' 217 | 218 | # Oscar Authentification configurations 219 | AUTHENTICATION_BACKENDS = ( 220 | 'oscar.apps.customer.auth_backends.EmailBackend', 221 | 'django.contrib.auth.backends.ModelBackend', 222 | ) 223 | 224 | TEMPLATES = [ 225 | { 226 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 227 | 'DIRS': [os.path.join(BASE_DIR, 'templates')], 228 | 'APP_DIRS': True, 229 | 'OPTIONS': { 230 | 'context_processors': [ 231 | 'django.template.context_processors.debug', 232 | 'django.template.context_processors.request', 233 | 'django.contrib.auth.context_processors.auth', 234 | 'django.contrib.messages.context_processors.messages', 235 | # Oscar specific 236 | 'oscar.apps.search.context_processors.search_form', 237 | 'oscar.apps.customer.notifications.context_processors.notifications', 238 | 'oscar.apps.promotions.context_processors.promotions', 239 | 'oscar.apps.checkout.context_processors.checkout', 240 | 'oscar.core.context_processors.metadata', 241 | ], 242 | }, 243 | }, 244 | ] 245 | 246 | WSGI_APPLICATION = '#{PROJ_NAME}.wsgi.application' 247 | 248 | SITE_ID = 1 249 | # Database 250 | # https://docs.djangoproject.com/en/1.11/ref/settings/#databases 251 | 252 | if PROD: # For production docker use 253 | DATABASES = { 254 | 'default': { 255 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', 256 | 'NAME': os.environ.get('POSTGRES_DB'), 257 | 'USER': os.environ.get('POSTGRES_USER'), 258 | 'PASSWORD': os.environ.get('POSTGRES_PASSWORD'), 259 | 'HOST': os.environ.get('POSTGRES_HOST'), 260 | 'PORT': os.environ.get('POSTGRES_PORT'), 261 | } 262 | } 263 | else: # For localhost development 264 | # DATABASES = { 265 | # 'default': { 266 | # 'ENGINE': 'django.db.backends.postgresql_psycopg2', 267 | # 'NAME': '#{POSGRES_DB_NAME}', 268 | # 'USER': '#{POSGRES_DB_USER}', 269 | # 'PASSWORD': '#{POSGRES_DB_PASSWORD}', 270 | # 'HOST': 'localhost', 271 | # 'PORT': '5432', 272 | # } 273 | # } 274 | DATABASES = { 275 | 'default': { 276 | 'ENGINE': 'django.db.backends.sqlite3', 277 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 278 | } 279 | } 280 | 281 | # Haystack Configuration for Oscar Applications 282 | HAYSTACK_CONNECTIONS = { 283 | 'default': { 284 | 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine', 285 | }, 286 | } 287 | 288 | # Oscar default currency 289 | OSCAR_DEFAULT_CURRENCY = 'AZN' 290 | 291 | # Password validation 292 | # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators 293 | 294 | AUTH_PASSWORD_VALIDATORS = [ 295 | { 296 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 297 | }, 298 | { 299 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 300 | }, 301 | { 302 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 303 | }, 304 | { 305 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 306 | }, 307 | ] 308 | 309 | # Internationalization 310 | MODELTRANSLATION_DEFAULT_LANGUAGE = 'en' 311 | # https://docs.djangoproject.com/en/1.11/topics/i18n/ 312 | 313 | LANGUAGE_CODE = 'en' 314 | 315 | LANGUAGES = ( 316 | ('en', _('English')), 317 | ('ru', _('Russian')), 318 | ('az', _('Azerbaijani')), 319 | ) 320 | 321 | TIME_ZONE = 'Asia/Dubai' 322 | 323 | USE_I18N = True 324 | 325 | USE_L10N = True 326 | 327 | USE_TZ = True 328 | 329 | # Static files (CSS, JavaScript, Images) 330 | # https://docs.djangoproject.com/en/1.11/howto/static-files/ 331 | 332 | STATIC_URL = '/static/' 333 | 334 | if PROD: 335 | STATIC_ROOT = os.path.join(BASE_DIR, "static") 336 | else: 337 | STATICFILES_DIRS = [ 338 | os.path.join(BASE_DIR, "static") 339 | ] 340 | 341 | # STATIC_ROOT = 'static' 342 | 343 | MEDIA_URL = '/media/' 344 | MEDIA_ROOT = os.path.join(BASE_DIR, "media") 345 | 346 | # ---------------------------- 347 | # ------------Logging....... 348 | 349 | LOG_LEVEL = 'ERROR' if PROD else 'DEBUG' 350 | LOGGING = { 351 | 'version': 1, 352 | 'disable_existing_loggers': not DEBUG, 353 | 'formatters': { 354 | 'standard': { 355 | 'format': '%(asctime)s [%(levelname)s] %(name)s:=> %(message)s', 356 | }, 357 | 'focused': { 358 | 'format': '\n----------------------\n%(asctime)s [%(levelname)s] %(name)s:=> %(message)s \n----------------------', 359 | }, 360 | }, 361 | } 362 | -------------------------------------------------------------------------------- /tlp/django_app/oscar_urls.py: -------------------------------------------------------------------------------- 1 | """#{PROJ_NAME} URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.11/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.conf.urls import url, include 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 | """ 16 | from django.conf.urls import url, include 17 | from django.contrib import admin 18 | from django.conf import settings 19 | from django.conf.urls.static import static 20 | # from django.conf.urls.i18n import i18n_patterns # for url translation 21 | from oscar.app import application # oscar applications urls here 22 | 23 | 24 | urlpatterns = [ 25 | url(r'^labmin/', admin.site.urls), 26 | url(r'^', include("#{APP_NAME}.urls")), 27 | url(r'^', application.urls), 28 | ] 29 | 30 | # urlpatterns += i18n_patterns( 31 | # url(r'^', include("#{APP_NAME}.urls")), 32 | # url(r'^', application.urls), 33 | # url(r'^page/', include('django.contrib.flatpages.urls')), 34 | # ) 35 | 36 | if 'rosetta' in settings.INSTALLED_APPS: 37 | urlpatterns += [ 38 | url(r'^translation/', include('rosetta.urls')) 39 | ] 40 | 41 | # in development django built-in server serves static and media content 42 | if not settings.PROD: 43 | urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) 44 | urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 45 | 46 | # This is change default admin panel Headers and titles 47 | admin.site.site_header = '#{PROJ_NAME} Admin' 48 | admin.site.site_title = '#{PROJ_NAME} Administration' 49 | admin.site.index_title = '#{PROJ_NAME} Administration' 50 | -------------------------------------------------------------------------------- /tlp/django_app/requirements.txt: -------------------------------------------------------------------------------- 1 | amqp==2.3.2 2 | billiard==3.5.0.4 3 | celery==4.2.0 4 | certifi==2018.4.16 5 | chardet==3.0.4 6 | defusedxml==0.5.0 7 | Django==2.0.1 8 | django-celery-beat==1.1.1 9 | django-celery-results==1.0.1 10 | django-ckeditor==5.4.0 11 | django-cleanup==2.1.0 12 | django-js-asset==1.1.0 13 | django-widget-tweaks==1.4.2 14 | gunicorn==19.7.1 15 | idna==2.7 16 | kombu==4.2.1 17 | oauthlib==2.1.0 18 | Pillow==5.1.0 19 | psycopg2==2.7.4 20 | psycopg2-binary==2.7.5 21 | PyJWT==1.6.4 22 | python3-openid==3.1.0 23 | pytz==2018.4 24 | redis==2.10.6 25 | requests==2.19.1 26 | requests-oauthlib==1.0.0 27 | six==1.11.0 28 | Unidecode==1.0.23 29 | urllib3==1.23 30 | uWSGI==2.0.17 31 | vine==1.1.4 -------------------------------------------------------------------------------- /tlp/django_app/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for #{PROJ_NAME} project. 3 | 4 | Generated by 'django-admin startproject' using Django 1.11. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.11/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/1.11/ref/settings/ 11 | """ 12 | 13 | import os 14 | from django.utils.translation import ugettext_lazy as _ 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | # Quick-start development settings - unsuitable for production 19 | # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ 20 | 21 | # SECURITY WARNING: keep the secret key used in production secret! 22 | SECRET_KEY = "#{SECRET_KEY}" 23 | # SECURITY WARNING: don't run with debug turned on in production! 24 | DEBUG = False if os.environ.get('DEBUG', False) == "False" else True 25 | PROD = not DEBUG 26 | 27 | ALLOWED_HOSTS = ['*'] if PROD else ['*'] 28 | 29 | # Email configuration 30 | # change your custom smtp configuration 31 | EMAIL_HOST = 'smtp.****' 32 | EMAIL_HOST_USER = 'noreply@email.net' 33 | EMAIL_HOST_PASSWORD = 'mnbvcxzas' 34 | EMAIL_PORT = 465 35 | EMAIL_USE_TLS = False 36 | EMAIL_USE_SSL = True 37 | DEFAULT_FROM_EMAIL = "#{PROJ_NAME} <%s>" % EMAIL_HOST_USER 38 | 39 | # Application definition 40 | # Locale translation files here 41 | # LOCALE_PATHS = ( 42 | # os.path.join(BASE_DIR, 'locale'), 43 | # ) 44 | # If you have a custom user uncommend 45 | AUTH_USER_MODEL = "base_user.MyUser" 46 | 47 | # Default login required 48 | # LOGIN_URL = '/accounts/login/' 49 | # Application definition 50 | 51 | 52 | INSTALLED_APPS = [ 53 | 'django.contrib.admin', 54 | 'django.contrib.auth', 55 | 'django.contrib.contenttypes', 56 | 'django.contrib.sessions', 57 | 'django.contrib.messages', 58 | 'django.contrib.staticfiles', 59 | 'django.contrib.sites', 60 | 'django.contrib.flatpages', 61 | 'social_core', # Python Social auth 62 | 'social_django', # Django Social auth 63 | 'celery', # Don't forget to add celery 64 | 'django_celery_results', # celery result 65 | 'django_celery_beat', 66 | 'ckeditor', 67 | 'ckeditor_uploader', 68 | 'widget_tweaks', 69 | 'base_user.apps.BaseUserConfig', 70 | # 'api.apps.ApiConfig', 71 | '#{APP_NAME}.apps.#{DJANGO_UP_APP_NAME}Config', 72 | ] 73 | 74 | # Ckeditor config 75 | CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' 76 | CKEDITOR_UPLOAD_PATH = "uploads/" 77 | 78 | CKEDITOR_CONFIGS = { 79 | 'default': { 80 | 'skin': 'moono', 81 | # 'skin': 'office2013', 82 | 'toolbar_Basic': [ 83 | ['Source', '-', 'Bold', 'Italic'] 84 | ], 85 | 'toolbar_YouCustomToolbarConfig': [ 86 | {'name': 'document', 'items': ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates']}, 87 | {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']}, 88 | {'name': 'editing', 'items': ['Find', 'Replace', '-', 'SelectAll']}, 89 | {'name': 'forms', 90 | 'items': ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 91 | 'HiddenField']}, 92 | '/', 93 | {'name': 'basicstyles', 94 | 'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']}, 95 | {'name': 'paragraph', 96 | 'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 97 | 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 98 | 'Language']}, 99 | {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']}, 100 | {'name': 'insert', 101 | 'items': ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe']}, 102 | '/', 103 | {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']}, 104 | {'name': 'colors', 'items': ['TextColor', 'BGColor']}, 105 | {'name': 'tools', 'items': ['Maximize', 'ShowBlocks']}, 106 | {'name': 'about', 'items': ['About']}, 107 | '/', # put this to force next toolbar on new line 108 | {'name': 'youcustomtools', 'items': [ 109 | # put the name of your editor.ui.addButton here 110 | 'Preview', 111 | 'Maximize', 112 | ]}, 113 | ], 114 | 'toolbar': 'YouCustomToolbarConfig', # put selected toolbar config here 115 | # 'toolbarGroups': [{ 'name': 'document', 'groups': [ 'mode', 'document', 'doctools' ] }], 116 | # 'height': 291, 117 | # 'width': '100%', 118 | # 'filebrowserWindowHeight': 725, 119 | # 'filebrowserWindowWidth': 940, 120 | # 'toolbarCanCollapse': True, 121 | # 'mathJaxLib': '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML', 122 | 'tabSpaces': 4, 123 | 'extraPlugins': ','.join( 124 | [ 125 | # you extra plugins here 126 | 'div', 127 | 'autolink', 128 | 'autoembed', 129 | 'embedsemantic', 130 | 'autogrow', 131 | # 'devtools', 132 | 'widget', 133 | 'lineutils', 134 | 'clipboard', 135 | 'dialog', 136 | 'dialogui', 137 | 'elementspath' 138 | ]), 139 | } 140 | } 141 | 142 | 143 | MIDDLEWARE = [ 144 | 'django.middleware.security.SecurityMiddleware', 145 | '#{PROJ_NAME}.middleware.force_default_middleware.force_default_language_middleware', 146 | 'django.contrib.sessions.middleware.SessionMiddleware', 147 | 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', 148 | 'django.middleware.common.CommonMiddleware', 149 | 'django.middleware.csrf.CsrfViewMiddleware', 150 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 151 | 'django.contrib.messages.middleware.MessageMiddleware', 152 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 153 | 'social_django.middleware.SocialAuthExceptionMiddleware', # if you want to social login uncomment this 154 | # 'app.middleware.game_session_middleware.game_check_session', # custom middleware 155 | ] 156 | 157 | ROOT_URLCONF = '#{PROJ_NAME}.urls' 158 | 159 | TEMPLATES = [ 160 | { 161 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 162 | 'DIRS': [os.path.join(BASE_DIR, "templates")], 163 | 'APP_DIRS': True, 164 | 'OPTIONS': { 165 | 'context_processors': [ 166 | 'django.template.context_processors.debug', 167 | 'django.template.context_processors.request', 168 | 'django.contrib.auth.context_processors.auth', 169 | 'django.contrib.messages.context_processors.messages', 170 | ], 171 | }, 172 | }, 173 | ] 174 | 175 | WSGI_APPLICATION = '#{PROJ_NAME}.wsgi.application' 176 | 177 | # Authentication backend 178 | # If you have social login activate this 179 | AUTHENTICATION_BACKENDS = ( 180 | 'social_core.backends.github.GithubOAuth2', 181 | 'social_core.backends.twitter.TwitterOAuth', 182 | 'social_core.backends.facebook.FacebookOAuth2', 183 | 184 | 'django.contrib.auth.backends.ModelBackend', 185 | ) 186 | 187 | SOCIAL_AUTH_PIPELINE = ( 188 | 'social_core.pipeline.social_auth.social_details', 189 | 'social_core.pipeline.social_auth.social_uid', 190 | 'social_core.pipeline.social_auth.social_user', 191 | 'social_core.pipeline.user.get_username', 192 | 'social_core.pipeline.user.create_user', 193 | 'social_core.pipeline.social_auth.associate_user', 194 | 'social_core.pipeline.social_auth.load_extra_data', 195 | 'social_core.pipeline.user.user_details', 196 | 'social_core.pipeline.social_auth.associate_by_email', 197 | # 'app.pipeline.get_avatar', # custom pipeline 198 | ) 199 | 200 | SOCIAL_AUTH_LOGIN_ERROR_URL = '/' 201 | SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/dashboard/' 202 | SOCIAL_AUTH_FACEBOOK_KEY = '******************' # App ID 203 | SOCIAL_AUTH_FACEBOOK_SECRET = '****************************' # App Secret 204 | SOCIAL_AUTH_FACEBOOK_SCOPE = ['email'] 205 | SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = { 206 | 'fields': 'id,name,email', 207 | } 208 | 209 | # logout redirect url 210 | LOGOUT_URL = 'logout' 211 | LOGIN_REDIRECT_URL = '/dashboard/' 212 | LOGIN_ERROR_URL = '/' 213 | 214 | SITE_ID = 1 215 | 216 | 217 | # Database 218 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 219 | 220 | # Celery backend result 221 | # CELERY_RESULT_BACKEND = 'django-db' 222 | 223 | if PROD: # For production docker use 224 | DATABASES = { 225 | 'default': { 226 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', 227 | 'NAME': os.environ.get('POSTGRES_DB'), 228 | 'USER': os.environ.get('POSTGRES_USER'), 229 | 'PASSWORD': os.environ.get('POSTGRES_PASSWORD'), 230 | 'HOST': os.environ.get('POSTGRES_HOST'), 231 | 'PORT': os.environ.get('POSTGRES_PORT'), 232 | } 233 | } 234 | else: # For localhost development 235 | # DATABASES = { 236 | # 'default': { 237 | # 'ENGINE': 'django.db.backends.postgresql_psycopg2', 238 | # 'NAME': '#{POSGRES_DB_NAME}', 239 | # 'USER': '#{POSGRES_DB_USER}', 240 | # 'PASSWORD': '#{POSGRES_DB_PASSWORD}', 241 | # 'HOST': 'localhost', 242 | # 'PORT': '5432', 243 | # } 244 | # } 245 | DATABASES = { 246 | 'default': { 247 | 'ENGINE': 'django.db.backends.sqlite3', 248 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 249 | } 250 | } 251 | 252 | # Password validation 253 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 254 | 255 | AUTH_PASSWORD_VALIDATORS = [ 256 | { 257 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 258 | }, 259 | { 260 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 261 | }, 262 | { 263 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 264 | }, 265 | { 266 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 267 | }, 268 | ] 269 | 270 | # Internationalization 271 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 272 | 273 | LANGUAGE_CODE = 'az' 274 | 275 | TIME_ZONE = 'Asia/Dubai' 276 | 277 | USE_I18N = True 278 | 279 | USE_L10N = True 280 | 281 | USE_TZ = True 282 | 283 | # Static files (CSS, JavaScript, Images) 284 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 285 | 286 | STATIC_URL = '/static/' 287 | if PROD: 288 | STATIC_ROOT = os.path.join(BASE_DIR, "static") 289 | else: 290 | STATICFILES_DIRS = [ 291 | os.path.join(BASE_DIR, "static") 292 | ] 293 | 294 | MEDIA_URL = '/media/' 295 | MEDIA_ROOT = os.path.join(BASE_DIR, "media") 296 | 297 | # ---------------------------- 298 | # ------------Logging....... 299 | 300 | LOG_LEVEL = 'ERROR' if PROD else 'DEBUG' 301 | LOGGING = { 302 | 'version': 1, 303 | 'disable_existing_loggers': not DEBUG, 304 | 'formatters': { 305 | 'standard': { 306 | 'format': '%(asctime)s [%(levelname)s] %(name)s:=> %(message)s', 307 | }, 308 | 'focused': { 309 | 'format': '\n----------------------\n%(asctime)s [%(levelname)s] %(name)s:=> %(message)s \n----------------------', 310 | }, 311 | }, 312 | } 313 | -------------------------------------------------------------------------------- /tlp/django_app/settings_django2.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for #{PROJ_NAME} project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.1. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | from django.utils.translation import ugettext_lazy as _ 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | # Quick-start development settings - unsuitable for production 19 | # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ 20 | 21 | # SECURITY WARNING: keep the secret key used in production secret! 22 | SECRET_KEY = "#{SECRET_KEY}" 23 | 24 | # SECURITY WARNING: don't run with debug turned on in production! 25 | DEBUG = not os.environ.get("DEBUG", False) 26 | PROD = not DEBUG 27 | 28 | ALLOWED_HOSTS = ['*'] if PROD else ['*'] 29 | 30 | # Email configuration 31 | # change your custom smtp configuration 32 | EMAIL_HOST = 'smtp.****' 33 | EMAIL_HOST_USER = 'noreply@email.net' 34 | EMAIL_HOST_PASSWORD = 'mnbvcxzas' 35 | EMAIL_PORT = 465 36 | EMAIL_USE_TLS = False 37 | EMAIL_USE_SSL = True 38 | DEFAULT_FROM_EMAIL = EMAIL_HOST_USER 39 | 40 | # Application definition 41 | # If you have a custom user uncommend 42 | AUTH_USER_MODEL = "base_user.MyUser" 43 | 44 | INSTALLED_APPS = [ 45 | 'django.contrib.admin', 46 | 'django.contrib.auth', 47 | 'django.contrib.contenttypes', 48 | 'django.contrib.sessions', 49 | 'django.contrib.messages', 50 | 'django.contrib.staticfiles', 51 | 'django.contrib.sites', 52 | 'django.contrib.flatpages', 53 | # 'social_core', # Python Social auth 54 | # 'social_django', # Django Social auth 55 | 'celery', # Don't forget to add celery 56 | 'django_celery_results', # celery result 57 | 'django_celery_beat', 58 | 'ckeditor', 59 | 'ckeditor_uploader', 60 | 'widget_tweaks', 61 | 'base_user.apps.BaseUserConfig', 62 | # 'api.apps.ApiConfig', 63 | '#{APP_NAME}.apps.#{DJANGO_UP_APP_NAME}Config', 64 | ] 65 | 66 | # Ckeditor config 67 | CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' 68 | CKEDITOR_UPLOAD_PATH = "uploads/" 69 | 70 | CKEDITOR_CONFIGS = { 71 | 'default': { 72 | 'skin': 'moono', 73 | # 'skin': 'office2013', 74 | 'toolbar_Basic': [ 75 | ['Source', '-', 'Bold', 'Italic'] 76 | ], 77 | 'toolbar_YouCustomToolbarConfig': [ 78 | {'name': 'document', 'items': ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates']}, 79 | {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']}, 80 | {'name': 'editing', 'items': ['Find', 'Replace', '-', 'SelectAll']}, 81 | {'name': 'forms', 82 | 'items': ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 83 | 'HiddenField']}, 84 | '/', 85 | {'name': 'basicstyles', 86 | 'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']}, 87 | {'name': 'paragraph', 88 | 'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 89 | 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 90 | 'Language']}, 91 | {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']}, 92 | {'name': 'insert', 93 | 'items': ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe']}, 94 | '/', 95 | {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']}, 96 | {'name': 'colors', 'items': ['TextColor', 'BGColor']}, 97 | {'name': 'tools', 'items': ['Maximize', 'ShowBlocks']}, 98 | {'name': 'about', 'items': ['About']}, 99 | '/', # put this to force next toolbar on new line 100 | {'name': 'youcustomtools', 'items': [ 101 | # put the name of your editor.ui.addButton here 102 | 'Preview', 103 | 'Maximize', 104 | ]}, 105 | ], 106 | 'toolbar': 'YouCustomToolbarConfig', # put selected toolbar config here 107 | # 'toolbarGroups': [{ 'name': 'document', 'groups': [ 'mode', 'document', 'doctools' ] }], 108 | # 'height': 291, 109 | # 'width': '100%', 110 | # 'filebrowserWindowHeight': 725, 111 | # 'filebrowserWindowWidth': 940, 112 | # 'toolbarCanCollapse': True, 113 | # 'mathJaxLib': '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML', 114 | 'tabSpaces': 4, 115 | 'extraPlugins': ','.join( 116 | [ 117 | # you extra plugins here 118 | 'div', 119 | 'autolink', 120 | 'autoembed', 121 | 'embedsemantic', 122 | 'autogrow', 123 | # 'devtools', 124 | 'widget', 125 | 'lineutils', 126 | 'clipboard', 127 | 'dialog', 128 | 'dialogui', 129 | 'elementspath' 130 | ]), 131 | } 132 | } 133 | 134 | 135 | MIDDLEWARE = [ 136 | 'django.middleware.security.SecurityMiddleware', 137 | '#{PROJ_NAME}.middleware.force_default_middleware.force_default_language_middleware', 138 | 'django.contrib.sessions.middleware.SessionMiddleware', 139 | 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', 140 | 'django.middleware.common.CommonMiddleware', 141 | 'django.middleware.csrf.CsrfViewMiddleware', 142 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 143 | 'django.contrib.messages.middleware.MessageMiddleware', 144 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 145 | # 'social_django.middleware.SocialAuthExceptionMiddleware', # if you want to social login uncomment this 146 | # 'app.middleware.game_session_middleware.game_check_session', # custom middleware 147 | ] 148 | 149 | ROOT_URLCONF = '#{PROJ_NAME}.urls' 150 | 151 | TEMPLATES = [ 152 | { 153 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 154 | 'DIRS': [os.path.join(BASE_DIR, "templates")], 155 | 'APP_DIRS': True, 156 | 'OPTIONS': { 157 | 'context_processors': [ 158 | 'django.template.context_processors.debug', 159 | 'django.template.context_processors.request', 160 | 'django.contrib.auth.context_processors.auth', 161 | 'django.contrib.messages.context_processors.messages', 162 | ], 163 | }, 164 | }, 165 | ] 166 | 167 | WSGI_APPLICATION = '#{PROJ_NAME}.wsgi.application' 168 | 169 | # Authentication backend 170 | # If you have social login activate this 171 | # AUTHENTICATION_BACKENDS = ( 172 | # 'social_core.backends.github.GithubOAuth2', 173 | # 'social_core.backends.twitter.TwitterOAuth', 174 | # 'social_core.backends.facebook.FacebookOAuth2', 175 | 176 | # 'django.contrib.auth.backends.ModelBackend', 177 | # ) 178 | 179 | # SOCIAL_AUTH_PIPELINE = ( 180 | # 'social_core.pipeline.social_auth.social_details', 181 | # 'social_core.pipeline.social_auth.social_uid', 182 | # 'social_core.pipeline.social_auth.social_user', 183 | # 'social_core.pipeline.user.get_username', 184 | # 'social_core.pipeline.user.create_user', 185 | # 'social_core.pipeline.social_auth.associate_user', 186 | # 'social_core.pipeline.social_auth.load_extra_data', 187 | # 'social_core.pipeline.user.user_details', 188 | # 'social_core.pipeline.social_auth.associate_by_email', 189 | # 'app.pipeline.get_avatar', # custom pipeline 190 | # ) 191 | 192 | # SOCIAL_AUTH_LOGIN_ERROR_URL = '/' 193 | # SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/dashboard/' 194 | # SOCIAL_AUTH_FACEBOOK_KEY = '******************' # App ID 195 | # SOCIAL_AUTH_FACEBOOK_SECRET = '****************************' # App Secret 196 | # SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'user_friends'] 197 | # SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = { 198 | # 'fields': 'id,name,email', 199 | # } 200 | 201 | # logout redirect url 202 | LOGOUT_URL = 'logout' 203 | LOGIN_REDIRECT_URL = '/dashboard/' 204 | LOGIN_ERROR_URL = '/' 205 | 206 | SITE_ID = 1 207 | 208 | 209 | # Database 210 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 211 | 212 | # Celery backend result 213 | CELERY_RESULT_BACKEND = 'django-db' 214 | 215 | if PROD: # For production docker use 216 | DATABASES = { 217 | 'default': { 218 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', 219 | 'NAME': os.environ.get('POSTGRES_DB'), 220 | 'USER': os.environ.get('POSTGRES_USER'), 221 | 'PASSWORD': os.environ.get('POSTGRES_PASSWORD'), 222 | 'HOST': os.environ.get('POSTGRES_HOST'), 223 | 'PORT': os.environ.get('POSTGRES_PORT'), 224 | } 225 | } 226 | else: # For localhost development 227 | # DATABASES = { 228 | # 'default': { 229 | # 'ENGINE': 'django.db.backends.postgresql_psycopg2', 230 | # 'NAME': '#{POSGRES_DB_NAME}', 231 | # 'USER': '#{POSGRES_DB_USER}', 232 | # 'PASSWORD': '#{POSGRES_DB_PASSWORD}', 233 | # 'HOST': 'localhost', 234 | # 'PORT': '5432', 235 | # } 236 | # } 237 | DATABASES = { 238 | 'default': { 239 | 'ENGINE': 'django.db.backends.sqlite3', 240 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 241 | } 242 | } 243 | 244 | # Password validation 245 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 246 | 247 | AUTH_PASSWORD_VALIDATORS = [ 248 | { 249 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 250 | }, 251 | { 252 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 253 | }, 254 | { 255 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 256 | }, 257 | { 258 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 259 | }, 260 | ] 261 | 262 | # Internationalization 263 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 264 | 265 | LANGUAGE_CODE = 'az' 266 | 267 | TIME_ZONE = 'Asia/Dubai' 268 | 269 | USE_I18N = True 270 | 271 | USE_L10N = True 272 | 273 | USE_TZ = True 274 | 275 | # Static files (CSS, JavaScript, Images) 276 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 277 | 278 | STATIC_URL = '/static/' 279 | if PROD: 280 | STATIC_ROOT = os.path.join(BASE_DIR, "static") 281 | else: 282 | STATICFILES_DIRS = [ 283 | os.path.join(BASE_DIR, "static") 284 | ] 285 | 286 | MEDIA_URL = '/media/' 287 | MEDIA_ROOT = os.path.join(BASE_DIR, "media") 288 | 289 | # ---------------------------- 290 | # ------------Logging....... 291 | 292 | LOG_LEVEL = 'ERROR' if PROD else 'DEBUG' 293 | LOGGING = { 294 | 'version': 1, 295 | 'disable_existing_loggers': not DEBUG, 296 | 'formatters': { 297 | 'standard': { 298 | 'format': '%(asctime)s [%(levelname)s] %(name)s:=> %(message)s', 299 | }, 300 | 'focused': { 301 | 'format': '\n----------------------\n%(asctime)s [%(levelname)s] %(name)s:=> %(message)s \n----------------------', 302 | }, 303 | }, 304 | } 305 | -------------------------------------------------------------------------------- /tlp/django_app/urls.py: -------------------------------------------------------------------------------- 1 | """#{PROJ_NAME} URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.11/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.conf.urls import url, include 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 | """ 16 | from django.conf.urls import url, include 17 | from django.contrib import admin 18 | from django.conf import settings 19 | from django.conf.urls.static import static 20 | # from django.conf.urls.i18n import i18n_patterns # for url translation 21 | # from oscar.app import application # oscar applications urls here 22 | 23 | 24 | urlpatterns = [ 25 | url(r'^labmin/', admin.site.urls), 26 | url(r'^', include("#{APP_NAME}.urls")), 27 | ] 28 | 29 | # urlpatterns += i18n_patterns( 30 | # url(r'^', include("#{APP_NAME}.urls")), 31 | # url(r'^', application.urls), 32 | # url(r'^page/', include('django.contrib.flatpages.urls')), 33 | # ) 34 | 35 | # in development django built-in server serves static and media content 36 | if not settings.PROD: 37 | urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) 38 | urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 39 | 40 | # This is change default admin panel Headers and titles 41 | admin.site.site_header = '#{PROJ_NAME} Admin' 42 | admin.site.site_title = '#{PROJ_NAME} Administration' 43 | admin.site.index_title = '#{PROJ_NAME} Administration' 44 | -------------------------------------------------------------------------------- /tlp/django_app/urls_django2.py: -------------------------------------------------------------------------------- 1 | """#{PROJ_NAME} URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | from django.conf import settings 19 | # if you have multilang website uncomment 20 | from django.conf.urls.static import static 21 | # from django.conf.urls.i18n import i18n_patterns # for url translation 22 | # from oscar.app import application # oscar applications urls here 23 | 24 | 25 | 26 | urlpatterns = [ 27 | path('admin/', admin.site.urls), 28 | path('', include("#{APP_NAME}.urls")), 29 | path('page/', include('django.contrib.flatpages.urls')), 30 | # path('social-login/', include('social_django.urls', namespace='social')), 31 | path('ckeditor/', include('ckeditor_uploader.urls')), 32 | ] 33 | # if you have multilang website uncomment 34 | # urlpatterns += i18n_patterns( 35 | # url(r'^', include("#{APP_NAME}.urls")), 36 | # url(r'^', application.urls), 37 | # url(r'^page/', include('django.contrib.flatpages.urls')), 38 | # ) 39 | 40 | 41 | 42 | # handler404 = 'game.views.NotFoundPage.as_view' 43 | 44 | # in development django built-in server serves static and media content 45 | if not settings.PROD: 46 | urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) 47 | urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 48 | # This is change default admin panel Headers and titles 49 | admin.site.site_header = '#{PROJ_NAME} Admin' 50 | admin.site.site_title = '#{PROJ_NAME} Administration' 51 | admin.site.index_title = '#{PROJ_NAME} Administration' 52 | 53 | --------------------------------------------------------------------------------