Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Integrate django-npm and django-bower
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Jun 26, 2016
1 parent ecbe2c0 commit 1addc41
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "components/"
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ db.sqlite3
.env
/static/
src/
/.config/
/.ipython/

31 changes: 27 additions & 4 deletions SMSFlyCRM/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
) # set default values and casting
environ.Env.read_env() # reading .env file


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'npm.finders.NpmFinder',
'djangobower.finders.BowerFinder',
)

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env('SECRET_KEY',
Expand Down Expand Up @@ -53,6 +56,7 @@
'debug_toolbar',
'recurrence',
'smart_selects',
'djangobower',
]

MIDDLEWARE_CLASSES = [
Expand Down Expand Up @@ -159,7 +163,8 @@
# https://docs.djangoproject.com/en/1.9/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = env('STATIC_ROOT', default=BASE_DIR('static'))
STATIC_ROOT_DIR = env.path('STATIC_ROOT', BASE_DIR('static'))
STATIC_ROOT = STATIC_ROOT_DIR()

SMS_FLY = {
'login': env('SMSFLY_ID'),
Expand Down Expand Up @@ -218,3 +223,21 @@
# Django Smart Selects:
USE_DJANGO_JQUERY = False
JQUERY_URL = '//about:blank' # hack around loading jquery to prevent it from breaking datepicker

NPM_FILE_PATTERNS = {
# 'angular2': ['*.js', '*.map'],
# 'es6-shim': ['es6-shim.min.js', 'es6-shim.map'],
# 'systemjs': ['dist/*.js', '*.map'],
# 'rxjs': ['bundles/Rx.js', '*.js', '*.map'],
# 'ng2-material': ['*.css', '*.js', '*.map', '*.ts']
}

NPM_DESTINATION_PREFIX = 'js/lib'

# BOWER_COMPONENTS_ROOT = STATIC_ROOT_DIR('js/lib/components')
BOWER_COMPONENTS_ROOT = BASE_DIR()

BOWER_INSTALLED_APPS = (
'jquery#1.9',
'underscore',
)
24 changes: 24 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "crm-smsfly",
"version": "1.0.0",
"homepage": "https://github.com/wk-tech/crm-smsfly",
"authors": [
"Anna Kurylo",
"Sviatoslav Sydorenko"
],
"description": "Embedded integration of some CRM with SMS-Fly gateway via iframe",
"keywords": [
"sms",
"campaign",
"gateway"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"static/js/lib/components/",
"test",
"tests"
]
}
7 changes: 7 additions & 0 deletions deploy/roles/smsapp/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

- apt: name=python3.5 state=present
- apt: name=python3.5-dev state=present
- apt: name=nodejs state=present
- apt: name=git state=present
- apt: name=libmysql++-dev state=present
- apt: name=libpq-dev state=present
Expand All @@ -28,6 +29,12 @@
- pip: name=virtualenv executable=pip3
- pip: requirements=/home/smsapp/repo/requirements.txt virtualenv=/home/smsapp/venv virtualenv_command=virtualenv virtualenv_python=python3.5

- npm: name=bower global=yes path=/home/smsapp/repo state=present
- npm: path=/home/smsapp/repo

- name: Install bower deps
command: "/home/smsapp/venv/bin/python manage.py bower install -- --allow-root"

- name: Add env file
template: 'src=smsapp.env dest=/home/smsapp/smsapp.env mode=0644'

Expand Down
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "crm-smsfly",
"version": "1.0.0",
"description": "Embedded integration of some CRM with SMS-Fly gateway via iframe",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/wk-tech/crm-smsfly.git"
},
"keywords": [
"sms",
"campaign",
"gateway"
],
"author": "Anna Kurylo",
"contributors": [
"Sviatoslav Sydorenko"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/wk-tech/crm-smsfly/issues"
},
"homepage": "https://github.com/wk-tech/crm-smsfly#readme"
}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
arrow==0.7.0
Django==1.9.7
django-bootstrap3==7.0.1
django-bower==5.1.0
django-cache-url==1.0.0
django-datetime-widget==0.9.3
django-debug-toolbar==1.4
django-environ==0.4.0
django-extensions==1.6.7
django-npm==1.0.0
django-recurrence==1.3.0
django-rq==0.9.1
django-rq-jobs==0.1.5.1
Expand Down
24 changes: 19 additions & 5 deletions vagga.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ containers:
- postgresql-dev
- mariadb-dev
- gcc
- !NpmInstall [bower]
- !Py3Install
- setuptools
- pip
Expand All @@ -41,6 +42,8 @@ containers:
- 'django-datetime-widget >=0.9.3,<1.0'
- 'django-recurrence >=1.3.0,<1.4'
- 'django-smart-selects >=1.2.2,<1.3'
- 'django-npm >=1.0.0,<1.1'
- 'django-bower >=5.1.0,<5.2'
- 'ipython >=4.2.0,<4.3'
- 'ipdb >=0.10.0,<1.0'
- 'Werkzeug >=0.11.4,<0.12'
Expand All @@ -49,6 +52,8 @@ containers:
- !Sh pip uninstall --yes SMSFly
- !Sh pip freeze > requirements.txt
- !Sh echo '-e git+https://github.com/wk-tech/[email protected]#egg=smsfly' >> requirements.txt
# - !Sh pip install -r requirements.txt
# - !Sh python3 manage.py bower --pythonpath=/work freeze
django:
setup:
- !Alpine v3.3
Expand All @@ -60,13 +65,16 @@ containers:
- libpq
- mariadb-client
- mariadb-dev
- nodejs
- sqlite
- git
- gcc
- !PipConfig
dependencies: true
- !Py3Requirements requirements.txt
- !NpmInstall [bower]
environ:
HOME: /work
DATABASE_URL: sqlite:///db.sqlite3
redis:
setup:
Expand Down Expand Up @@ -118,15 +126,21 @@ commands:
app: !Command
container: django
environ:
HOME: /work
CACHE_URL: memcached://127.0.0.1:11211
run: python3 manage.py runserver_plus --traceback
run: |
echo "from npm.finders import npm_install; npm_install()" | python3 ./manage.py shell --pythonpath=$HOME
python3 ./manage.py bower --pythonpath=$HOME install -- --allow-root
python3 manage.py runserver_plus --pythonpath=$HOME --traceback
rq: !Command
container: django
environ:
HOME: /work
run: |
python3 manage.py rqscheduler --pythonpath=/work &
while [ true ]; do sleep 60; python3 manage.py rqjobs --pythonpath=/work; done &
while [ true ]; do sleep 1800; python3 manage.py sms_campaign_scheduler --pythonpath=/work 30; done &
python3 manage.py rqworker --pythonpath=/work high default low
python3 manage.py rqscheduler --pythonpath=$HOME &
while [ true ]; do sleep 60; python3 manage.py rqjobs --pythonpath=$HOME; done &
while [ true ]; do sleep 1800; python3 manage.py sms_campaign_scheduler --pythonpath=$HOME 30; done &
python3 manage.py rqworker --pythonpath=$HOME high default low
redis: !Command
container: redis
run: |
Expand Down

0 comments on commit 1addc41

Please sign in to comment.