Skip to content

Commit f9e09eb

Browse files
committed
Initial commit
0 parents  commit f9e09eb

20 files changed

+551
-0
lines changed

config/__init__.py

Whitespace-only changes.

config/settings.py

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
"""
2+
Django settings for DjangoFacebookLogin 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+
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+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = 'yl(&kwsts+41%lifbqc0a!*f4w%_v5!*vpp9)r66fb$#ec4tj8'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = ['*']
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
'material',
41+
'material.frontend',
42+
'unifi_portal'
43+
]
44+
45+
MIDDLEWARE = [
46+
'django.middleware.security.SecurityMiddleware',
47+
'django.contrib.sessions.middleware.SessionMiddleware',
48+
'django.middleware.common.CommonMiddleware',
49+
'django.middleware.csrf.CsrfViewMiddleware',
50+
'django.contrib.auth.middleware.AuthenticationMiddleware',
51+
'django.contrib.messages.middleware.MessageMiddleware',
52+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
53+
]
54+
55+
ROOT_URLCONF = 'config.urls'
56+
57+
TEMPLATES = [
58+
{
59+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
60+
'DIRS': [os.path.join(BASE_DIR, 'templates')]
61+
,
62+
'APP_DIRS': True,
63+
'OPTIONS': {
64+
'context_processors': [
65+
'django.template.context_processors.debug',
66+
'django.template.context_processors.request',
67+
'django.contrib.auth.context_processors.auth',
68+
'django.contrib.messages.context_processors.messages',
69+
'django.template.context_processors.i18n',
70+
'material.frontend.context_processors.modules',
71+
],
72+
},
73+
},
74+
]
75+
76+
WSGI_APPLICATION = 'config.wsgi.application'
77+
78+
# shortcut for in form templates
79+
try:
80+
# shortcut for in form templates
81+
from django.template.base import add_to_builtins
82+
add_to_builtins('material.templatetags.material_form')
83+
except ImportError:
84+
"""
85+
Django 1.9.
86+
"""
87+
TEMPLATES[0]['OPTIONS']['builtins'] = [
88+
'material.templatetags.material_form',
89+
]
90+
91+
92+
# Database
93+
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
94+
95+
DATABASES = {
96+
'default': {
97+
'ENGINE': 'django.db.backends.sqlite3',
98+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
99+
}
100+
}
101+
102+
103+
# Password validation
104+
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
105+
106+
AUTH_PASSWORD_VALIDATORS = [
107+
{
108+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
109+
},
110+
{
111+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
112+
},
113+
{
114+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
115+
},
116+
{
117+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
118+
},
119+
]
120+
121+
122+
# Internationalization
123+
# https://docs.djangoproject.com/en/1.11/topics/i18n/
124+
125+
LANGUAGE_CODE = 'en-us'
126+
127+
TIME_ZONE = 'UTC'
128+
129+
USE_I18N = True
130+
131+
USE_L10N = True
132+
133+
USE_TZ = True
134+
135+
136+
# Static files (CSS, JavaScript, Images)
137+
# https://docs.djangoproject.com/en/1.11/howto/static-files/
138+
139+
STATIC_URL = '/static/'

config/urls.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""DjangoFacebookLogin 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 material.frontend import urls as frontend_urls
19+
20+
from unifi_portal import urls as unifi_urls
21+
22+
urlpatterns = [
23+
#url(r'^admin/', admin.site.urls),
24+
url(r'', include(unifi_urls)),
25+
#url(r'', include(frontend_urls)),
26+
]

config/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for DjangoFacebookLogin project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
15+
16+
application = get_wsgi_application()

manage.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
7+
try:
8+
from django.core.management import execute_from_command_line
9+
except ImportError:
10+
# The above import may fail for some other reason. Ensure that the
11+
# issue is really that Django is missing to avoid masking other
12+
# exceptions on Python 2.
13+
try:
14+
import django
15+
except ImportError:
16+
raise ImportError(
17+
"Couldn't import Django. Are you sure it's installed and "
18+
"available on your PYTHONPATH environment variable? Did you "
19+
"forget to activate a virtual environment?"
20+
)
21+
raise
22+
execute_from_command_line(sys.argv)

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Django==1.11
2+
django-material

runtime.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-2.7.13

templates/base.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>{% block title %}Django Unifi Portal{% endblock %}</title>
8+
9+
{% block head %}
10+
{% include 'material/includes/material_css.html' %}
11+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
12+
13+
<style type="text/css">
14+
html, body {
15+
background: #eee;
16+
height: 100%;
17+
}
18+
</style>
19+
{% block extrahead %}{% endblock %}
20+
{% endblock %}
21+
</head>
22+
<body class="valign-wrapper2">
23+
{% block sidebar %}{% endblock %}
24+
<div class="{% block container_class %}container expand-on-small-only{% endblock %}">
25+
{% block content %}{% endblock %}
26+
</div>
27+
{% block js %}
28+
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
29+
{% include 'material/includes/material_js.html' %}
30+
{% block extrajs %}{% endblock %}
31+
{% endblock %}
32+
</body>
33+
</html>

templates/base_form.html

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{% extends 'base.html' %}
2+
3+
{% block extrahead %}
4+
<style type="text/css">
5+
@media only screen and (min-width : 601px) {
6+
#id_card_type_container {
7+
margin-top: 40px;
8+
margin-left: 50px;
9+
}
10+
}
11+
</style>
12+
{% endblock %}
13+
14+
{% block content %}
15+
<div class="row valign change-form">
16+
<div class="{% block formclass %}col s12 m8 offset-m2 l8 offset-l2{% endblock %}">
17+
<div class="card">
18+
<form method="POST" enctype="multipart/form-data">
19+
<div class="card-content">
20+
<span class="card-title grey-text text-darken-2">{% block formtitle %}Form{% endblock %}</span>
21+
{% csrf_token %}
22+
{% block formbody %}{% endblock %}
23+
</div>
24+
<div class="card-action">
25+
{% block actions %}
26+
<div class="right-align">
27+
{% block formbuttons %}<button class="btn btn-primary" type="submit">Submit</button>{% endblock %}
28+
</div>
29+
{% endblock %}
30+
</div>
31+
</form>
32+
</div>
33+
</div>
34+
</div>
35+
{% block result %}
36+
{% endblock %}
37+
{% endblock %}

templates/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Django Unifi Portal</title>
6+
</head>
7+
<body>
8+
9+
</body>
10+
</html>

templates/login.html

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{% extends 'base_form.html' %}
2+
{% load material_form %}
3+
4+
{% block extrahead %}
5+
<style type="text/css">
6+
{{ form.css }}
7+
</style>
8+
{% endblock %}
9+
10+
{% block formclass %}{{ form.blockclass|default:"col s12 m8 offset-m2 l8 offset-l2" }}{% endblock %}
11+
12+
{% block formtitle %}{{ form.title }}{% endblock %}
13+
14+
{% block formbody %}
15+
16+
{% include form.social_buttons %}
17+
18+
<h5 style="text-align:center">or</h5>
19+
20+
{% include form.template %}
21+
{% endblock %}
22+
23+
{% block formbuttons %}
24+
{% include form.buttons %}
25+
26+
<div class="row">
27+
<div class="checkbox-field col s12 required" id="id_terms_accepted_container">
28+
<label for="id_terms_accepted">If you click "Log in with Facebook" and are not a user, you will be registered and you agree to Terms & Conditions and Privacy Policy.</label>
29+
</div>
30+
</div>
31+
32+
{% endblock %}

templates/registration.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{% extends 'base_form.html' %}
2+
{% load material_form %}
3+
4+
{% block extrahead %}
5+
<style type="text/css">
6+
{{ form.css }}
7+
</style>
8+
{% endblock %}
9+
10+
{% block formclass %}{{ form.blockclass|default:"col s12 m8 offset-m2 l8 offset-l2" }}{% endblock %}
11+
12+
{% block formtitle %}{{ form.title }}{% endblock %}
13+
14+
{% block formbody %}
15+
{% include form.template %}
16+
{% endblock %}
17+
18+
{% block formbuttons %}
19+
{% include form.buttons %}
20+
{% endblock %}

unifi_portal/__init__.py

Whitespace-only changes.

unifi_portal/form_mixin.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import django
2+
from django.forms import * # NOQA
3+
from material.base import LayoutMixin as ViewformLayoutMixin
4+
5+
6+
class SourceCodeMixin(object):
7+
def source(self):
8+
import inspect
9+
import itertools
10+
11+
lines = inspect.getsourcelines(self.__class__)[0]
12+
lines = [x for x in itertools.takewhile(lambda x: not x.strip().startswith('template'), lines)]
13+
return ''.join(lines)
14+
15+
16+
class Form(SourceCodeMixin, django.forms.Form):
17+
pass
18+
19+
20+
class LayoutMixin(SourceCodeMixin, ViewformLayoutMixin):
21+
pass

0 commit comments

Comments
 (0)