Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
microcood committed Nov 7, 2015
0 parents commit 2f80a1f
Show file tree
Hide file tree
Showing 53 changed files with 8,323 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .openshift/action_hooks/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [ ! -f "$OPENSHIFT_DATA_DIR"secrets.json ]; then
echo "Generating $OPENSHIFT_DATA_DIR/secrets.json"
python "$OPENSHIFT_REPO_DIR"libs/secrets.py > "$OPENSHIFT_DATA_DIR"secrets.json
fi


echo "Executing 'python $OPENSHIFT_REPO_DIR/manage.py migrate --noinput'"
python "$OPENSHIFT_REPO_DIR"/manage.py migrate --noinput


echo "Executing 'python $OPENSHIFT_REPO_DIR/manage.py collectstatic --noinput'"
python "$OPENSHIFT_REPO_DIR"/manage.py collectstatic --noinput
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DSURVEY
===================

this shit most likely doesn't work on python less than 3.3

some commands that might help to install:

./setup.py install
Empty file added app/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions app/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin
from django.contrib.auth.models import *

admin.site.unregister(User)
admin.site.unregister(Group)
159 changes: 159 additions & 0 deletions app/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
"""
Django settings for app project.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
DJ_PROJECT_DIR = os.path.dirname(__file__)
BASE_DIR = DJ_PROJECT_DIR
WSGI_DIR = DJ_PROJECT_DIR
REPO_DIR = os.path.dirname(WSGI_DIR)
DATA_DIR = os.environ.get('OPENSHIFT_DATA_DIR', BASE_DIR)

import sys
sys.path.append(os.path.join(REPO_DIR, 'libs'))
import secrets
SECRETS = secrets.getter(os.path.join(DATA_DIR, 'secrets.json'))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = SECRETS['secret_key']
LOGIN_REDIRECT_URL = '/'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DEBUG', False)

from socket import gethostname
ALLOWED_HOSTS = [
gethostname(), # For internal OpenShift load balancer security purposes.
os.environ.get('OPENSHIFT_APP_DNS', 'localhost'), # Dynamically map to the OpenShift gear name.
#'example.com', # First DNS alias (set up in the app)
#'www.example.com', # Second DNS alias (set up in the app)
]

LANGUAGE_CODE = 'ru'
# Application definition

INSTALLED_APPS = (
'frontend',

'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'foundationform',
'app',
'tracking',
'survey',

)

MIDDLEWARE_CLASSES = (
'tracking.middleware.VisitorTrackingMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'app.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': False,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'loaders': [
'django.template.loaders.app_directories.Loader',
'django.template.loaders.filesystem.Loader'
]
},
},
]

WSGI_APPLICATION = 'wsgi.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
# GETTING-STARTED: change 'db.sqlite3' to your sqlite3 database:
'NAME': os.path.join(DATA_DIR, 'db.sqlite3'),
}
}

LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
},
'loggers': {
'django': {
'handlers': ['null'],
'level': 'ERROR',
'propagate': True,
},
}
}


# make all loggers use the console.
for logger in LOGGING['loggers']:
LOGGING['loggers'][logger]['handlers'] = ['console']

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(REPO_DIR, 'wsgi', 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
11 changes: 11 additions & 0 deletions app/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.conf.urls import include, url
from django.contrib import admin
from survey.views import WelcomeRedirectView


urlpatterns = [
url(r'^$', WelcomeRedirectView.as_view(), name="welcome"),
url(r'^manage/', include(admin.site.urls)),
url(r'^survey/', include('survey.urls')),
url(r'^fantasyland/visits/', include('tracking.urls')),
]
1 change: 1 addition & 0 deletions foundationform/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION = (0, 2)
Empty file added foundationform/models.py
Empty file.
22 changes: 22 additions & 0 deletions foundationform/runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
import django
from django.conf import settings
from django.core.management import call_command


if not settings.configured:
settings.configure(
INSTALLED_APPS=('foundationform',),
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':MEMORY:',
}
},
)

if __name__ == "__main__":
if django.VERSION[1] > 5:
call_command('test', 'foundationform.tests')
else:
call_command('test', 'foundationform')
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div class="row{% if field.errors %} error{% endif %}">
{% if inline %}
<div class="large-3 columns">
<label for="{{ field.auto_id }}" class="right inline">
{{ field.label }}
</label>
</div>
<div class="large-9 columns">
{{ field }}
{% for error in field.errors %}
<small{% if field.errors %} class="error"{% endif %}>{{ error|escape }}</small>
{% endfor %}
</div>
{% else %}
<div class="large-12 columns">
<label>
{{ field.label }}
{{ field }}
</label>
{% for error in field.errors %}
<small{% if field.errors %} class="error"{% endif %}>{{ error|escape }}</small>
{% endfor %}
</div>
{% endif %}
</div>
15 changes: 15 additions & 0 deletions foundationform/templates/foundationform/foundation_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% if form.non_field_errors %}
<div data-alert="" class="alert-box alert">
{% for non_field_error in form.non_field_errors %}
{{ non_field_error }}
{% endfor %}
</div>
{% endif %}

{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}

{% for field in form.visible_fields %}
{% include 'foundationform/_foundation_form_field.html' %}
{% endfor %}
29 changes: 29 additions & 0 deletions foundationform/templates/foundationform/foundation_formset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="hide">
<div id="{{ formset.prefix }}_empty_form">
<div class="formset-form">
<div class="large-11 columns">
{% include 'foundationform/foundation_form.html' with form=formset.empty_form %}
</div>
<div class="large-1 columns">
<a href="#" class="close formset-delete-form">&times;</a>
</div>
</div>
</div>
</div>
<div class="{{ formset.prefix }}-item-formset">
{{ formset.management_form }}

{% for item_form in formset %}
<div class="formset-form">
<div class="large-11 columns">
{% include 'foundationform/foundation_form.html' with form=item_form %}
</div>
<div class="large-1 columns">
{% if formset.can_delete %}
<a href="#" class="close formset-delete-form">&times;</a>
{% endif %}
</div>
</div>
{% endfor %}
<a href="#" class="button secondary small formset-add-form">Add item</a>
</div>
Empty file.
35 changes: 35 additions & 0 deletions foundationform/templatetags/foundation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from django.template import Context
from django.template.loader import get_template
from django.template import Library


register = Library()


def get_context_template(element):
element_type = element.__class__.__name__.lower()

if element_type == 'boundfield':
template = get_template("foundationform/_foundation_form_field.html")
context = Context({'field': element})
else:
if hasattr(element, 'management_form'):
template = get_template("foundationform/foundation_formset.html")
context = Context({'formset': element})
else:
template = get_template("foundationform/foundation_form.html")
context = Context({'form': element})
return template, context


@register.filter
def foundation(element):
template, context = get_context_template(element)
return template.render(context)


@register.filter
def foundationinline(element):
template, context = get_context_template(element)
context.update({'inline': True})
return template.render(context)
28 changes: 28 additions & 0 deletions foundationform/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from django import forms
from django.test import TestCase
from django.template import Template, Context


class TestForm(forms.Form):
text = forms.CharField(label='text')


class FilterTest(TestCase):
def setUp(self):
self.context = Context({'form': TestForm()})

def test_base_render(self):
template = Template('{% load foundation %}{{ form|foundation }}')
rendered = template.render(self.context)
self.assertIn('class="large-12 columns"', rendered)
self.assertIn('class="row"', rendered)

def test_inline_filter(self):
template = Template('{% load foundation %}{{ form|foundationinline }}')
rendered = template.render(self.context)
self.assertIn('class="large-3 columns"', rendered)

def test_field_render(self):
template = Template('{% load foundation %}{{ form.text|foundation }}')
rendered = template.render(self.context)
self.assertIn('class="large-12 columns"', rendered)
Empty file added frontend/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions frontend/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "iqline-django-frontend",
"description": "",
"main": "index.js",
"authors": [
"Micwaits Microcood <microcood@gmail.com>"
],
"license": "ISC",
"moduleType": [],
"homepage": "",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"devDependencies": {
"foundation": "~5.5.3",
"livereload-js": "livereload#~2.2.1"
}
}
Loading

0 comments on commit 2f80a1f

Please sign in to comment.