Commit 3d48c11b by interrogator

initial commit

parents
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Packaging files:
*.egg*
# Sphinx docs:
build
# SQLite3 database files:
*.db
*.sqlite3
*.sqlite
# Logs:
*.log
# Environment variables
local.env
# Django stuff:
*.mo
*.pot
# Eclipse
.project
.pydevproject
.settings
# Linux Editors
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
.elc
auto-save-list
tramp
.\#*
*.swp
*.swo
# Rope
.ropeproject
# Mac
.DS_Store
._*
# Windows
Thumbs.db
Desktop.ini
# Project settings
./site/
language: python
python:
- "2.7"
- "3.4"
install:
- pip install -r requirements.txt
- cd ..
- django-admin startproject --template=./edge --extension=py,md,html,env wugsy
- cd wugsy/src
- cp wugsy/settings/local.sample.env wugsy/settings/local.env
- python manage.py migrate
script:
- python manage.py test profiles
# wugsy
wugsy is a _short description_. It is built with [Python][0] using the [Django Web Framework][1].
This project has the following basic apps:
* App1 (short desc)
* App2 (short desc)
* App3 (short desc)
## Installation
### Quick start
To set up a development environment quickly, first install Python 3. It
comes with virtualenv built-in. So create a virtual env by:
1. `$ python3 -m venv wugsy`
2. `$ . wugsy/bin/activate`
Install all dependencies:
pip install -r requirements.txt
Run migrations:
python manage.py migrate
### Detailed instructions
Take a look at the docs for more information.
[0]: https://www.python.org/
[1]: https://www.djangoproject.com/
Welcome to wugsy!
==============================
\ No newline at end of file
* `django.log`: Contains logs by Django framework like executed SQL statements
* `project.log`: Contains logs from the `project` logger. For example:
# At the top of your file/module
import logging
logger = logging.getLogger("project")
# Anywhere else in the file
logger.info('Started processing foo')
-r requirements/development.txt
Django>=1.11.3
django-environ>=0.4.3
django-braces>=1.11.0
django-crispy-forms>=1.6.1
django-admin-bootstrapped>=2.5.7
django-authtools>=1.6.0
easy-thumbnails>=2.4.1
-r base.txt
django-debug-toolbar>=1.8
Werkzeug>=0.12.2
-r base.txt
# Extra stuff required for production like Prod Database interfacing packages
# psycopg2
from django.contrib import admin
# Register your models here.
from __future__ import unicode_literals
from django.contrib.auth.forms import AuthenticationForm
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field
from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions
from authtools import forms as authtoolsforms
from django.contrib.auth import forms as authforms
from django.core.urlresolvers import reverse
class LoginForm(AuthenticationForm):
remember_me = forms.BooleanField(required=False, initial=False)
def __init__(self, *args, **kwargs):
super(LoginForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.fields["username"].widget.input_type = "email" # ugly hack
self.helper.layout = Layout(
Field('username', placeholder="Enter Email", autofocus=""),
Field('password', placeholder="Enter Password"),
HTML('<a href="{}">Forgot Password?</a>'.format(
reverse("accounts:password-reset"))),
Field('remember_me'),
Submit('sign_in', 'Log in',
css_class="btn btn-lg btn-primary btn-block"),
)
class SignupForm(authtoolsforms.UserCreationForm):
def __init__(self, *args, **kwargs):
super(SignupForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.fields["email"].widget.input_type = "email" # ugly hack
self.helper.layout = Layout(
Field('email', placeholder="Enter Email", autofocus=""),
Field('name', placeholder="Enter Full Name"),
Field('password1', placeholder="Enter Password"),
Field('password2', placeholder="Re-enter Password"),
Submit('sign_up', 'Sign up', css_class="btn-warning"),
)
class PasswordChangeForm(authforms.PasswordChangeForm):
def __init__(self, *args, **kwargs):
super(PasswordChangeForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field('old_password', placeholder="Enter old password",
autofocus=""),
Field('new_password1', placeholder="Enter new password"),
Field('new_password2', placeholder="Enter new password (again)"),
Submit('pass_change', 'Change Password', css_class="btn-warning"),
)
class PasswordResetForm(authtoolsforms.FriendlyPasswordResetForm):
def __init__(self, *args, **kwargs):
super(PasswordResetForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field('email', placeholder="Enter email",
autofocus=""),
Submit('pass_reset', 'Reset Password', css_class="btn-warning"),
)
class SetPasswordForm(authforms.SetPasswordForm):
def __init__(self, *args, **kwargs):
super(SetPasswordForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field('new_password1', placeholder="Enter new password",
autofocus=""),
Field('new_password2', placeholder="Enter new password (again)"),
Submit('pass_change', 'Change Password', css_class="btn-warning"),
)
from django.db import models
# Create your models here.
{% extends "base.html" %}
{% load crispy_forms_tags %}
{% block navbar %}
{% endblock %}
{% block container %}
<div class="container form-box">
<div class="text-center">
<h2>{% block form_heading %}{% endblock %}</h2>
</div>
{% block form %}
{% endblock %}
</div>
{% endblock container %}
{% load i18n %}{% autoescape off %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'accounts:password-reset-confirm' uidb64=uid token=token %}
{% endblock %}
{% trans "Your login email, in case you've forgotten, is same this email address:" %} {{ user.get_username }}
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
{% endautoescape %}
{% templatetag openblock %} load i18n {% templatetag closeblock %}{% templatetag openblock %} autoescape off {% templatetag closeblock %}
{% templatetag openblock %} blocktrans {% templatetag closeblock %}Password reset on {% templatetag openvariable %} site_name {% templatetag closevariable %}{% templatetag openblock %} endblocktrans {% templatetag closeblock %}
{% templatetag openblock %} endautoescape {% templatetag closeblock %}
{% extends "accounts/auth_base.html" %}
{% load crispy_forms_tags %}
{% block title %}{{ block.super }}Log In{% endblock %}
{% block form_heading %}Please Log In{% endblock %}
{% block form %}
{% crispy form %}
<div class="form-message">
<p>
Don't have an account? <a href="{% url 'accounts:signup' %}">Sign up</a>.
</p>
</div>
{% endblock form %}
{% extends "accounts/auth_base.html" %}
{% load crispy_forms_tags %}
{% block title %}{{ block.super }}Password Change{% endblock %}
{% block form_heading %}Password Change{% endblock %}
{% block form %}
{% crispy form %}
{% endblock form %}
{% extends "accounts/auth_base.html" %}
{% load crispy_forms_tags %}
{% block title %}{{ block.super }}Password Change{% endblock %}
{% block form_heading %}Password Change{% endblock %}
{% block form %}
{% crispy form %}
{% endblock form %}
{% extends "accounts/auth_base.html" %}
{% load crispy_forms_tags %}
{% block title %}{{ block.super }}Password Reset Done{% endblock %}
{% block form_heading %}Password Reset Email Sent{% endblock %}
{% block form %}
<div class="form-message">
<p>
Please check your mail. You would have received a password reset mail from us.
</p>
</div>
{% endblock form %}
{% extends "accounts/auth_base.html" %}
{% load crispy_forms_tags %}
{% block title %}{{ block.super }}Password Reset{% endblock %}
{% block form_heading %}Password Reset{% endblock %}
{% block form %}
{% crispy form %}
{% endblock form %}
{% extends "accounts/auth_base.html" %}
{% load crispy_forms_tags %}
{% block title %}{{ block.super }}Sign Up{% endblock %}
{% block form_heading %}Signing Up is Free{% endblock %}
{% block form %}
{% crispy form %}
<div class="form-message">
<p>
Already signed up? <a href="{% url 'accounts:login' %}">Log in</a>.
</p>
</div>
{% endblock form %}
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^login/$', views.LoginView.as_view(), name="login"),
url(r'^logout/$', views.LogoutView.as_view(), name='logout'),
url(r'^signup/$', views.SignUpView.as_view(), name='signup'),
url(r'^password-change/$', views.PasswordChangeView.as_view(),
name='password-change'),
url(r'^password-reset/$', views.PasswordResetView.as_view(),
name='password-reset'),
url(r'^password-reset-done/$', views.PasswordResetDoneView.as_view(),
name='password-reset-done'),
url(r'^password-reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$$', views.PasswordResetConfirmView.as_view(), # NOQA
name='password-reset-confirm'),
]
from __future__ import unicode_literals
from django.core.urlresolvers import reverse_lazy
from django.views import generic
from django.contrib.auth import get_user_model
from django.contrib import auth
from django.contrib import messages
from authtools import views as authviews
from braces import views as bracesviews
from django.conf import settings
from . import forms
User = get_user_model()
class LoginView(bracesviews.AnonymousRequiredMixin,
authviews.LoginView):
template_name = "accounts/login.html"
form_class = forms.LoginForm
def form_valid(self, form):
redirect = super(LoginView, self).form_valid(form)
remember_me = form.cleaned_data.get('remember_me')
if remember_me is True:
ONE_MONTH = 30*24*60*60
expiry = getattr(settings, "KEEP_LOGGED_DURATION", ONE_MONTH)
self.request.session.set_expiry(expiry)
return redirect
class LogoutView(authviews.LogoutView):
url = reverse_lazy('home')
class SignUpView(bracesviews.AnonymousRequiredMixin,
bracesviews.FormValidMessageMixin,
generic.CreateView):
form_class = forms.SignupForm
model = User
template_name = 'accounts/signup.html'
success_url = reverse_lazy('home')
form_valid_message = "You're signed up!"
def form_valid(self, form):
r = super(SignUpView, self).form_valid(form)
username = form.cleaned_data["email"]
password = form.cleaned_data["password1"]
user = auth.authenticate(email=username, password=password)
auth.login(self.request, user)
return r
class PasswordChangeView(authviews.PasswordChangeView):
form_class = forms.PasswordChangeForm
template_name = 'accounts/password-change.html'
success_url = reverse_lazy('home')
def form_valid(self, form):
form.save()
messages.success(self.request,
"Your password was changed, "
"hence you have been logged out. Please relogin")
return super(PasswordChangeView, self).form_valid(form)
class PasswordResetView(authviews.PasswordResetView):
form_class = forms.PasswordResetForm
template_name = 'accounts/password-reset.html'
success_url = reverse_lazy('accounts:password-reset-done')
subject_template_name = 'accounts/emails/password-reset-subject.txt'
email_template_name = 'accounts/emails/password-reset-email.html'
class PasswordResetDoneView(authviews.PasswordResetDoneView):
template_name = 'accounts/password-reset-done.html'
class PasswordResetConfirmView(authviews.PasswordResetConfirmAndLoginView):
template_name = 'accounts/password-reset-confirm.html'
form_class = forms.SetPasswordForm
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class GameConfig(AppConfig):
name = 'game'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class LangConfig(AppConfig):
name = 'lang'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
# CHANGED manage.py will use development settings by
# default. Change the DJANGO_SETTINGS_MODULE environment variable
# for using the environment specific settings file.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wugsy.settings.development")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
default_app_config = "profiles.apps.ProfileConfig"
from __future__ import unicode_literals
from django.contrib import admin
from authtools.admin import NamedUserAdmin
from .models import Profile
from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
User = get_user_model()
class UserProfileInline(admin.StackedInline):
model = Profile
class NewUserAdmin(NamedUserAdmin):
inlines = [UserProfileInline]
list_display = ('is_active', 'email', 'name', 'permalink',
'is_superuser', 'is_staff',)
# 'View on site' didn't work since the original User model needs to
# have get_absolute_url defined. So showing on the list display
# was a workaround.
def permalink(self, obj):
url = reverse("profiles:show",
kwargs={"slug": obj.profile.slug})
# Unicode hex b6 is the Pilcrow sign
return '<a href="{}">{}</a>'.format(url, '\xb6')
permalink.allow_tags = True
admin.site.unregister(User)
admin.site.register(User, NewUserAdmin)
from __future__ import unicode_literals
from django.apps import AppConfig
class ProfileConfig(AppConfig):
name = "profiles"
verbose_name = 'User Profiles'
def ready(self):
from . import signals # noqa
from __future__ import unicode_literals
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field
from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions
from django.contrib.auth import get_user_model
from . import models
User = get_user_model()
class UserForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(UserForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Field('name'),
)
class Meta:
model = User
fields = ['name']
class ProfileForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ProfileForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Field('picture'),
Field('bio'),
Submit('update', 'Update', css_class="btn-success"),
)
class Meta:
model = models.Profile
fields = ['picture', 'bio']
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
import uuid
class Migration(migrations.Migration):
dependencies = [
('auth', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Profile',
fields=[
('user', models.OneToOneField(serialize=False, primary_key=True, to=settings.AUTH_USER_MODEL)),
('slug', models.UUIDField(default=uuid.uuid4, blank=True, editable=False)),
('picture', models.ImageField(verbose_name='Profile picture', upload_to='profile_pics/%Y-%m-%d/', blank=True, null=True)),
('bio', models.CharField(verbose_name='Short Bio', max_length=200, blank=True, null=True)),
('email_verified', models.BooleanField(default=False, verbose_name='Email verified')),
],
options={
'abstract': False,
},
bases=(models.Model,),
),
]
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible
import uuid
from django.db import models
from django.conf import settings
class BaseProfile(models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL,
primary_key=True)
slug = models.UUIDField(default=uuid.uuid4, blank=True, editable=False)
# Add more user profile fields here. Make sure they are nullable
# or with default values
picture = models.ImageField('Profile picture',
upload_to='profile_pics/%Y-%m-%d/',
null=True,
blank=True)
bio = models.CharField("Short Bio", max_length=200, blank=True, null=True)
email_verified = models.BooleanField("Email verified", default=False)
class Meta:
abstract = True
@python_2_unicode_compatible
class Profile(BaseProfile):
def __str__(self):
return "{}'s profile". format(self.user)
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.conf import settings
import logging
from . import models
logger = logging.getLogger("project")
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_profile_handler(sender, instance, created, **kwargs):
if not created:
return
# Create the profile object, only if it is newly created
profile = models.Profile(user=instance)
profile.save()
logger.info('New user profile for {} created'.format(instance))
{% extends "base.html" %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% load thumbnail %}
{% block title %}{{ block.super }}Profile{% endblock %}
<!-- Benefits of the Django application -->
{% block container %}
<div class="container">
<h1 class="text-primary">Edit Profile</h1>
<hr>
<div class="row">
<!-- left column -->
<div class="col-md-3">
<div class="text-center">
<img title="profile picture" class="img-circle img-responsive" src="{% thumbnail user.profile.picture|default:'default_profile.png' 140x140 crop %}">
</div>
</div>
<!-- edit form column -->
<div class="col-md-9">
<h3>Personal info</h3>
<form enctype="multipart/form-data" method="post">
{% crispy user_form %}
{% crispy profile_form %}
</form>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<a class="btn btn-default pull-right" href="{% url 'accounts:password-change' %}">Change Password</a>
</div>
</div>
</div>
{% endblock %}
{% extends "base.html" %}
{% load staticfiles %}
{% load thumbnail %}
{% block title %}{{ block.super }}Profile{% endblock %}
{% block container %}
<div class="container profile-head">
<div class="row">
<div class="col-sm-10">
<h1>{{ show_user.get_full_name }}</h1>
{% if editable %}
<a href="{% url 'profiles:edit_self' %}" class="btn btn-info">Edit Profile</a>
{% endif %}
</div>
<div class="col-sm-2"><img title="profile picture" class="img-circle img-responsive" src="{% thumbnail show_user.profile.picture|default:'default_profile.png' 140x140 crop %}">
</div>
</div>
</div>
<div class="container profile-body">
<div class="row">
<div class="col-sm-4">
<ul class="list-group">
<li class="list-group-item text-muted">Profile</li>
<li class="list-group-item text-right"><span class="pull-left"><strong>Email:</strong></span> {{ show_user.email|default:"missing" }}
{% if show_user.profile.email_verified %}
<span class="glyphicon glyphicon-ok-circle" aria-hidden="true" title="This email address has been verified"></span>
<span class="sr-only">Verified</span>
{% else %}
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true" title="This email address is not verified"></span>
<span class="sr-only">Not Verified</span>
{% endif %}
</li>
<li class="list-group-item text-right"><span class="pull-left"><strong>Joined</strong></span> {{ show_user.date_joined }}</li>
<li class="list-group-item text-right"><span class="pull-left"><strong>Last seen</strong></span> {{ show_user.last_login }}</li>
</ul>
</div>
<div class="col-sm-8">
<div class="panel panel-default">
<div class="panel-heading">{{ show_user.get_full_name }}'s Profile
{% if show_user.profile.slug %}
<a href="{% url 'profiles:show' show_user.profile.slug %}">
<span class="glyphicon glyphicon-link" aria-hidden="true" title="Profile permalink"></span>
<span class="sr-only">Permalink</span></a> {{ show_user.profile.get_absolute_url }}
{% else %}
<a href="https://github.com/arocks/edge/issues/40" target="_blank"><span>No permalink. See this issue.</span></a>
{% endif %}
</div>
<div class="panel-body">
<strong>Bio</strong>: {{ show_user.profile.bio }}
</div>
</div>
</div>
</div>
</div>
{% endblock %}
from __future__ import unicode_literals
from django.test import TestCase
from django.core.urlresolvers import resolve, reverse
from django.contrib.auth import get_user_model
class PageOpenTestCase(TestCase):
def test_home_page_exists(self):
url = reverse('home')
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
def test_about_page_exists(self):
url = reverse('about')
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
User = get_user_model()
class ProfileTestCase(TestCase):
def test_profiles_created(self):
u = User.objects.create_user(email="dummy@example.com")
self.assertIsNotNone(u.profile)
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^me$', views.ShowProfile.as_view(), name='show_self'),
url(r'^me/edit$', views.EditProfile.as_view(), name='edit_self'),
url(r'^(?P<slug>[\w\-]+)$', views.ShowProfile.as_view(),
name='show'),
]
from __future__ import unicode_literals
from django.views import generic
from django.shortcuts import get_object_or_404, redirect
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from . import forms
from . import models
class ShowProfile(LoginRequiredMixin, generic.TemplateView):
template_name = "profiles/show_profile.html"
http_method_names = ['get']
def get(self, request, *args, **kwargs):
slug = self.kwargs.get('slug')
if slug:
profile = get_object_or_404(models.Profile, slug=slug)
user = profile.user
else:
user = self.request.user
if user == self.request.user:
kwargs["editable"] = True
kwargs["show_user"] = user
return super(ShowProfile, self).get(request, *args, **kwargs)
class EditProfile(LoginRequiredMixin, generic.TemplateView):
template_name = "profiles/edit_profile.html"
http_method_names = ['get', 'post']
def get(self, request, *args, **kwargs):
user = self.request.user
if "user_form" not in kwargs:
kwargs["user_form"] = forms.UserForm(instance=user)
if "profile_form" not in kwargs:
kwargs["profile_form"] = forms.ProfileForm(instance=user.profile)
return super(EditProfile, self).get(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
user = self.request.user
user_form = forms.UserForm(request.POST, instance=user)
profile_form = forms.ProfileForm(request.POST,
request.FILES,
instance=user.profile)
if not (user_form.is_valid() and profile_form.is_valid()):
messages.error(request, "There was a problem with the form. "
"Please check the details.")
user_form = forms.UserForm(instance=user)
profile_form = forms.ProfileForm(instance=user.profile)
return super(EditProfile, self).get(request,
user_form=user_form,
profile_form=profile_form)
# Both forms are fine. Time to save!
user_form.save()
profile = profile_form.save(commit=False)
profile.user = user
profile.save()
messages.success(request, "Profile details saved!")
return redirect("profiles:show_self")
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
@import "//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css";
html, body{
height:100%; /* For full height images */
}
.starter-template {
padding: 40px 15px;
text-align: center;
}
.footer {
padding-top: 40px;
padding-bottom: 40px;
margin-top: 40px;
border-top: 1px solid #eee;
}
.alert {
margin-top: 55px;
margin-bottom: 0;
}
body>.navbar-transparent {
background-color: transparent;
border-color: transparent;
box-shadow: none;
}
.navbar-transparent .navbar-nav > .active > a {
background-color: transparent;
}
.navbar-form {
margin-right: 0;
}
.navbar-nav>li>a.profile-menu {
padding-top: 10px;
padding-bottom: 10px;
}
.navbar-nav>.btn{
margin-top:10px;
margin-right: 1.7em;
}
.navbar-nav > li > a {
font-size: 16px;
}
.navbar-brand {
font-weight: bold;
}
.navbar-brand > img {
float: left;
margin-right: 10px;
}
.btn {
background-image: none;
-webkit-box-shadow: 0px 1px 0px #ddd;
-moz-box-shadow: 0px 1px 0px #ddd;
box-shadow: 0px 1px 0px #ddd;
}
/* Home page styling */
.corporate-jumbo {
background-image: linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0)),
url("/static/site/img/banner.jpg");
background-repeat: no-repeat;
background-position: 80% center;
background-attachment: fixed;
-webkit-background-size: cover;
background-size: cover;
color: #f5f5f5;
padding: 10em 0;
margin-bottom: 0;
height: 100%;
}
.corporate-jumbo .well {
background-color: rgba(245, 245, 245, .7);
}
.corporate-jumbo p, .corporate-jumbo h1 {
color: #eee;
text-shadow: 0px 0px 2px black;
}
.corporate-jumbo p {
font-weight: 500;
}
.corporate-jumbo .well legend {
color: #333;
}
.corporate-jumbo > .container {
display: block;
position: absolute;
bottom: 2em;
left: 15px;
}
.contact-banner {
padding: 100px 0;
background: #e0e0e0;
margin-top: 100px;
}
.footer a:hover {
text-decoration: none;
}
/* About page styling */
#sec1 {
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAJklEQVQIW2NkAIILFy78NzAwYATRjCABZEGwAEwFiA1WBlIOUwkA72gTdDIYVO4AAAAASUVORK5CYII=) repeat;
}
/* Profile page styling */
.profile-head {
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAJklEQVQIW2NkAIILFy78NzAwYATRjCABZEGwAEwFiA1WBlIOUwkA72gTdDIYVO4AAAAASUVORK5CYII=) repeat;
padding: 70px 0px 30px 20px;
}
.profile-body {
padding: 4px 0px;
}
.text-page {
padding: 120px 0;
}
#map-outer {
height: 440px;
padding: 40px 20px;
margin-bottom: 20px;
background-color:#FFF
}
#map-container {
height: 400px
}
.img-dim {
opacity: 0.5;
box-shadow: inset 0px 0px 64px 64px #EA1717, 0px 0px 4px 4px #EA1717;
}
/* Authentication forms */
.form-box form,
.form-box .form-message {
max-width: 330px;
padding: 15px;
margin: 0 auto;
}
.form-box form .checkbox {
margin-bottom: 10px;
}
.form-box form .checkbox {
font-weight: normal;
}
.form-box form .form-control {
position: relative;
height: auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
font-size: 16px;
}
.form-box form .form-control:focus {
z-index: 2;
}
\ No newline at end of file
(function(){
$(window).scroll(function () {
var top = $(document).scrollTop();
$('.corporate-jumbo').css({
'background-position': '0px -'+(top/3).toFixed(2)+'px'
});
if(top > 50)
$('.navbar').removeClass('navbar-transparent');
else
$('.navbar').addClass('navbar-transparent');
}).trigger('scroll');
})();
<li {% if active_link == "home" %}class="active"{% endif %}><a href="{% url 'home' %}">Home</a></li>
<li {% if active_link == "about" %}class="active"{% endif %}><a href="{% url 'about' %}">About</a></li>
{% extends "base.html" %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block title %}{{ block.super }}About{% endblock %}
{% block navbar-left %}
{% include "_navbar.html" with active_link="about" %}
{% endblock %}
<!-- Benefits of the Django application -->
{% block container %}
<div id="sec1" class="text-page">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<h1>{% include "_brandname.html" %}</h1>
<p class="lead">An Awesome Tagline Goes Here</p>
</div>
</div>
</div>
</div>
<div id="sec2" class="text-page">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<h2>Meet The Team</h2>
<p class="lead">The Wonderful People Behind the Site</p>
</div>
</div>
<div class="row">
<div class="col-lg-4">
<div class="text-center"><img class="img-circle centered" src="http://lorempixel.com/128/128/people/9/" alt="profile pic"></div>
<p class="heavy text-center">Cassidy Coder</p>
<h2>Front-end developer</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
</div>
<div class="col-lg-4">
<div class="text-center"><img class="img-circle centered" src="http://lorempixel.com/128/128/people/2/" alt="profile pic"></div>
<p class="heavy text-center">James King</p>
<h2>CEO</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
</div>
<div class="col-lg-4">
<div class="text-center"><img class="img-circle centered" src="http://lorempixel.com/128/128/people/1/" alt="profile pic"></div>
<p class="heavy text-center">Kate Lamport</p>
<h2>Front-end designer</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
</div>
</div>
</div>
</div>
</div>
<div id="sec3">
<div class="container">
<div class="row">
<div id="map-outer" class="col-md-12">
<div id="address" class="col-md-4">
<h2>Our Location</h2>
<address>
<strong>Edge Solutions Ltd.</strong><br>
Taj Mahal<br>
Agra<br>
Uttar Pradesh<br>
India - 282001<br>
<abbr>P:</abbr> +91 0562 222 6431
</address>
</div>
<div id="map-container" class="col-md-8"></div>
</div>
</div>
</div>
</div>
{% endblock container %}
{% block scripts %}
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script>
function init_map() {
// Enter the latitude and longitude of your office here
var myLocation = new google.maps.LatLng(27.176141, 78.042370);
var mapOptions = {
center: myLocation,
zoom: 14
};
var marker = new google.maps.Marker({
position: myLocation,
title:"We are here"});
var map = new google.maps.Map(document.getElementById("map-container"),
mapOptions);
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', init_map);
</script>
{% endblock scripts %}
{% include "_brandname.html" %} Admin
{% extends "admin/base.html" %}
{% load i18n %}{% load admin_static bootstrapped_goodies_tags %}
{% block title %}{% include "_brandname.html" %} Admin{% endblock %}
{% block branding %}
<a class="navbar-brand" href="{% url 'admin:index' %}">{% include "_brandname.html" %} Admin</a>
{% endblock %}
{% block nav-global %}
<a class="btn btn-default" href="{% url 'home' %}"><span class="glyphicon glyphicon-transfer" aria-hidden="true"></span> Switch to Site</a>
{% endblock %}
{% block extrahead %}{{ block.super }}
<link href="{% static 'site/css/main.css' %}" rel="stylesheet">
{% endblock %}
<!DOCTYPE html>
<html lang="en">
{% load staticfiles %}
{% load thumbnail %}
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="{% block description %}{% endblock description %}">
<meta name="author" content="Arun Ravindran">
<link rel="shortcut icon" href="{% static 'site/ico/favicon.ico' %}">
<title>{% block title %}{% include "_brandname.html" %} :: {% endblock %}</title>
<!-- Bootstrap core CSS -->
<link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
<!-- Custom styles for this site -->
{% block styles %}
<link href="{% static 'site/css/main.css' %}" rel="stylesheet">
{% endblock styles %}
<!-- Custom tags for the head tag -->
{% block extrahead %}{% endblock extrahead %}
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
{% block navbar %}
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{% url 'home' %}">
{% block navbar-brand %}
<img src="{% static 'site/img/logo.png' %}" alt="logo">
{% include "_brandname.html" %}
{% endblock %}
</a>
</div>
{% block navbar-menu %}
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
{% block navbar-left %}{% endblock %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% block navbar-right %}
{% if user.is_authenticated %}
{% if user.is_staff %}
<li><a href="{% url 'admin:index' %}">Admin</a></li>
{% endif %}
<li class="dropdown">
<a href="#" class="dropdown-toggle profile-menu" data-toggle="dropdown">
<img src="{% thumbnail user.profile.picture|default:'default_profile.png' 30x30 crop %}" alt="" />
{{ user.get_full_name|truncatechars:20 }}
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li><a href="{% url 'profiles:show_self' %}">Profile</a></li>
<li><a href="{% url 'accounts:logout' %}">Logout</a></li>
</ul>
</li>
{% endif %}
{% endblock %}
</ul>
</ul>
</div><!--/.nav-collapse -->
{% endblock %}
</div>
{% endblock navbar %}
{% block messages %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }}"> <!-- singular -->
<a class="close" data-dismiss="alert">×</a>
{{ message|safe }}
</div>
{% endfor %}
{% endif %}
{% endblock %}
{% block splash %}
{% endblock splash %}
{% block container %}
<div class="container">
<div class="starter-template">
<h1>New Project</h1>
<p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
</div>
</div><!-- /.container -->
{% endblock container %}
<!-- Site footer -->
{% block footer %}
<!-- Some social button for contact will do -->
<a name="contact"></a>
<div class="container">
<div class="footer">
<div class="row">
<div class="col-lg-6">
<p>&copy; Company {% now 'Y' %}</p>
</div>
<div class="col-lg-6 text-right">
Connect with us on
<a href="#"><i class="fa fa-facebook"></i> Facebook</a> or
<a href="#"><i class="fa fa-twitter"></i> Twitter</a>
</div>
</div>
</div>
</div>
{% endblock %}
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script>
{% block scripts %}
{% endblock scripts %}
</body>
</html>
{% extends "base.html" %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block title %}{{ block.super }}Home{% endblock %}
{% block navbar-left %}
{% include "_navbar.html" with active_link="home" %}
{% endblock %}
{% block navbar-right %}
{% if not user.is_authenticated %}
<a class="btn btn-default" href="{% url 'accounts:login' %}" role="button">Log in</a>
<a class="btn btn-primary" href="{% url 'accounts:signup' %}" role="button">Sign up</a>
{% else %}
{{ block.super }}
{% endif %}
{% endblock %}
{% block splash %}
<div class="jumbotron jumbotron-carousel corporate-jumbo">
<div class="container">
<div class="row">
<div class="col-md-8 col-sm-8">
<h1>{% include "_brandname.html" %}</h1>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam.</p>
<a class="btn btn-primary" href="{% url 'accounts:signup' %}" role="button">Sign up for Free!</a>
</div>
<div class="col-md-4 col-sm-4">
</div>
</div>
</div>
</div>
{% endblock splash %}
{% block container %}
<!-- Benefits of the Django application -->
<a name="about"></a>
<div class="container">
<div class="row">
<div class="col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.</p>
<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
</div>
</div>
</div>
{% endblock container %}
{% block scripts %}
<script src="{% static 'site/js/site.js' %}"></script>
{% endblock scripts %}
{% extends "admin/base_site.html" %}
{% load i18n %}
{% block breadcrumbs %}
{% endblock %}
{% block content %}
<p>{% trans "Thanks for spending some quality time with the Web site today." %}</p>
<p><a href="{% url 'admin:index' %}" class="btn btn-default">{% trans 'Log in again' %}</a></p>
{% endblock %}
{% extends "admin/base_site.html" %}
{% load i18n %}
{% block breadcrumbs %}
<ul class="breadcrumb">
<li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
<li>{% trans 'Password change' %}</li>
</ul>
{% endblock %}
{% block title %}{% trans 'Password change successful' %}{% endblock %}
{% block content_title %}<a class="navbar-brand">{% trans 'Password change successful' %}</a>{% endblock %}
{% block content %}
<p class="alert alert-success">{% trans 'Your password was changed.' %}</p>
{% endblock %}
{% extends "admin/base_site.html" %}
{% load i18n static bootstrapped_goodies_tags %}
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %}
{% block breadcrumbs %}
<ul class="breadcrumb">
<li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
<li>{% trans 'Password change' %}</a>
</ul>
{% endblock %}
{% block title %}{% trans 'Password change' %}{% endblock %}
{% block content_title %}<a class="navbar-brand">{% trans 'Password change' %}</a>{% endblock %}
{% block content %}<div id="content-main">
<form class="form-horizontal" action="" method="post">{% csrf_token %}
{% if form.errors %}
<div class="alert alert-danger">
{% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
</div>
{% endif %}
<div class="alert alert-info">{% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}</div>
<fieldset class="_module _aligned wide">
<div class="form-group">
<div class="control-label col-sm-2">
{{ form.old_password.label_tag }}
</div>
<div class="controls col-sm-10">
{% dab_field_rendering form.old_password %}
{% if form.old_password.errors %}<span class="text-danger">{{ form.old_password.errors|striptags }}</span>{% endif %}
</div>
</div>
<div class="form-group">
<div class="control-label col-sm-2">
{{ form.new_password1.label_tag }}
</div>
<div class="controls col-sm-10">
{% dab_field_rendering form.new_password1 %}
{% if form.new_password1.errors %} <span class="text-danger">{{ form.new_password1.errors|striptags }}</span>{% endif %}
{% if form.new_password1.help_text %}<span class="text-info">{{ form.new_password1.help_text }}</span>{% endif %}
</div>
</div>
<div class="form-group">
<div class="control-label col-sm-2">
{{ form.new_password2.label_tag }}
</div>
<div class="controls col-sm-10">
{% dab_field_rendering form.new_password2 %}
{% if form.new_password2.errors %} <span class="text-danger">{{ form.new_password2.errors|striptags }}</span>{% endif %}
{% if form.new_password2.help_text %}<span class="text-info">{{ form.new_password2.help_text }}</span>{% endif %}
</div>
</div>
</fieldset>
<div class="form-actions">
<div class="controls col-sm-offset-2 col-sm-10">
<input type="submit" value="{% trans 'Change my password' %}" class="default btn btn-primary" />
</div>
</div>
<script type="text/javascript">document.getElementById("id_old_password").focus();</script>
</form></div>
{% endblock %}
{% extends "admin/base_site.html" %}
{% load i18n %}
{% block breadcrumbs %}
<ul class="breadcrumb">
<li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
<li>{% trans 'Password reset complete' %}</a>
</ul>
{% endblock %}
{% block title %}{% trans 'Password reset complete' %}{% endblock %}
{% block content_title %}<a class="navbar-brand">{% trans 'Password reset complete' %}</a>{% endblock %}
{% block content %}
<p class="alert alert-success">{% trans "Your password has been set. You may go ahead and log in now." %}</p>
<p><a href="{{ login_url }}" class="btn btn-primary">{% trans 'Log in' %}</a></p>
{% endblock %}
{% extends "admin/base_site.html" %}
{% load i18n bootstrapped_goodies_tags %}
{% block breadcrumbs %}
<ul class="breadcrumb">
<li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
<li>{% trans 'Password reset confirmation' %}</li>
</ul>
{% endblock %}
{% block title %}{% trans 'Password reset' %}{% endblock %}
{% block content_title %}<a class="navbar-brand">{% trans 'Password reset' %}</a>{% endblock %}
{% block content %}
{% if validlink %}
<h1>{% trans 'Enter new password' %}</h1>
<p class="alert alert-info">{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>
<form class="form-horizontal" action="" method="post">{% csrf_token %}
<div class="form-group">
<div class="control-label col-sm-2">
<label for="id_new_password1">{% trans 'New password:' %}</label>
</div>
<div class="controls col-sm-10">
{% dab_field_rendering form.new_password1 %}
{% if form.new_password1.errors %}<span class="text-danger">{{ form.new_password1.errors|striptags }}</span>{% endif %}
</div>
</div>
<div class="form-group">
<div class="control-label col-sm-2">
<label for="id_new_password2">{% trans 'Confirm password:' %}</label>
</div>
<div class="controls col-sm-10">
{% dab_field_rendering form.new_password2 %}
{% if form.new_password2.errors %}<span class="text-danger">{{ form.new_password2.errors|striptags }}</span>{% endif %}
</div>
</div>
<div class="form-actions col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-primary" value="{% trans 'Change my password' %}" />
</div>
</form>
{% else %}
<h1>{% trans 'Password reset unsuccessful' %}</h1>
<p class="alert alert-warning">{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}</p>
{% endif %}
{% endblock %}
{% extends "admin/base_site.html" %}
{% load i18n %}
{% block breadcrumbs %}
<ul class="breadcrumb">
<li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
<li>{% trans 'Password reset' %}</li>
</ul>
{% endblock %}
{% block title %}{% trans 'Password reset successful' %}{% endblock %}
{% block content_title %}<a class="navbar-brand">{% trans 'Password reset successful' %}</a>{% endblock %}
{% block content %}
<p class="alert alert-success">{% trans "We've emailed you instructions for setting your password to the email address you submitted. You should be receiving it shortly." %}</p>
{% endblock %}
{% extends "admin/base_site.html" %}
{% load i18n bootstrapped_goodies_tags %}
{% block breadcrumbs %}
<ul class="breadcrumb">
<li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
<li>{% trans 'Password reset' %}</li>
</ul>
{% endblock %}
{% block title %}{% trans "Password reset" %}{% endblock %}
{% block content_title %}<a class="navbar-brand">{% trans "Password reset" %}</a>{% endblock %}
{% block content %}
<p class="alert alert-info">{% trans "Forgotten your password? Enter your email address below, and we'll email instructions for setting a new one." %}</p>
<form class="form-horizontal" action="" method="post">{% csrf_token %}
<div class="form-group">
<div class="control-label col-sm-2">
<label for="id_email">{% trans 'Email address:' %}</label>
</div>
<div class="controls col-sm-10">
{% dab_field_rendering form.email %}
{% if form.email.errors %}<span class="text-danger">{{ form.email.errors|striptags }}</span>{% endif %}
</div>
</div>
<div class="form-actions col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-primary" value="{% trans 'Reset my password' %}" />
</div>
</form>
{% endblock %}
# Support new str.format syntax in log messages
#
# Based on http://stackoverflow.com/a/25433007 and
# http://stackoverflow.com/a/26003573 and logging cookbook
# https://docs.python.org/3/howto/logging-cookbook.html#use-of-alternative-formatting-styles
#
# It's worth noting that this implementation has problems if key words
# used for brace substitution include level, msg, args, exc_info,
# extra or stack_info. These are argument names used by the log method
# of Logger. If you need to one of these names then modify process to
# exclude these names or just remove log_kwargs from the _log call. On
# a further note, this implementation also silently ignores misspelled
# keywords meant for the Logger (eg. ectra).
#
import logging
class NewStyleLogMessage(object):
def __init__(self, message, *args, **kwargs):
self.message = message
self.args = args
self.kwargs = kwargs
def __str__(self):
args = (i() if callable(i) else i for i in self.args)
kwargs = dict((k, v() if callable(v) else v)
for k, v in self.kwargs.items())
return self.message.format(*args, **kwargs)
N = NewStyleLogMessage
class StyleAdapter(logging.LoggerAdapter):
def __init__(self, logger, extra=None):
super(StyleAdapter, self).__init__(logger, extra or {})
def log(self, level, msg, *args, **kwargs):
if self.isEnabledFor(level):
msg, log_kwargs = self.process(msg, kwargs)
self.logger._log(level, N(msg, *args, **kwargs), (),
**log_kwargs)
logger = StyleAdapter(logging.getLogger("project"))
# Emits "Lazily formatted log entry: 123 foo" in log
# logger.debug('Lazily formatted entry: {0} {keyword}', 123, keyword='foo')
"""
Django settings for wugsy project.
For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""
from django.core.urlresolvers import reverse_lazy
from os.path import dirname, join, exists
# Build paths inside the project like this: join(BASE_DIR, "directory")
BASE_DIR = dirname(dirname(dirname(__file__)))
STATICFILES_DIRS = [join(BASE_DIR, 'static')]
MEDIA_ROOT = join(BASE_DIR, 'media')
MEDIA_URL = "/media/"
# Use Django templates using the new Django 1.8 TEMPLATES settings
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
join(BASE_DIR, 'templates'),
# insert more TEMPLATE_DIRS here
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
# list if you haven't customized them:
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
},
},
]
# Use 12factor inspired environment variables or from a file
import environ
env = environ.Env()
# Ideally move env file should be outside the git repo
# i.e. BASE_DIR.parent.parent
env_file = join(dirname(__file__), 'local.env')
if exists(env_file):
environ.Env.read_env(str(env_file))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
# Raises ImproperlyConfigured exception if SECRET_KEY not in os.environ
SECRET_KEY = env('SECRET_KEY')
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.auth',
'django_admin_bootstrapped',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'authtools',
'crispy_forms',
'easy_thumbnails',
'profiles',
'accounts',
)
MIDDLEWARE_CLASSES = (
'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 = 'wugsy.urls'
WSGI_APPLICATION = 'wugsy.wsgi.application'
# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
# Raises ImproperlyConfigured exception if DATABASE_URL not in
# os.environ
'default': env.db(),
}
# Internationalization
# https://docs.djangoproject.com/en/dev/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/dev/howto/static-files/
STATIC_URL = '/static/'
ALLOWED_HOSTS = []
# Crispy Form Theme - Bootstrap 3
CRISPY_TEMPLATE_PACK = 'bootstrap3'
# For Bootstrap 3, change error alert to 'danger'
from django.contrib import messages
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
# Authentication Settings
AUTH_USER_MODEL = 'authtools.User'
LOGIN_REDIRECT_URL = reverse_lazy("profiles:show_self")
LOGIN_URL = reverse_lazy("accounts:login")
THUMBNAIL_EXTENSION = 'png' # Or any extn for your thumbnails
from .base import * # NOQA
import sys
import logging.config
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATES[0]['OPTIONS'].update({'debug': True})
# Turn off debug while imported by Celery with a workaround
# See http://stackoverflow.com/a/4806384
if "celery" in sys.argv[0]:
DEBUG = False
# Django Debug Toolbar
INSTALLED_APPS += (
'debug_toolbar',)
# Additional middleware introduced by debug toolbar
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',)
# Show emails to console in DEBUG mode
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Show thumbnail generation errors
THUMBNAIL_DEBUG = True
# Allow internal IPs for debugging
INTERNAL_IPS = [
'127.0.0.1',
'0.0.0.1',
]
# Log everything to the logs directory at the top
LOGFILE_ROOT = join(dirname(BASE_DIR), 'logs')
# Reset logging
# (see http://www.caktusgroup.com/blog/2015/01/27/Django-Logging-Configuration-logging_config-default-settings-logger/)
LOGGING_CONFIG = None
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': "[%(asctime)s] %(levelname)s [%(pathname)s:%(lineno)s] %(message)s",
'datefmt': "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'django_log_file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': join(LOGFILE_ROOT, 'django.log'),
'formatter': 'verbose'
},
'proj_log_file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': join(LOGFILE_ROOT, 'project.log'),
'formatter': 'verbose'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
}
},
'loggers': {
'django': {
'handlers': ['django_log_file'],
'propagate': True,
'level': 'DEBUG',
},
'project': {
'handlers': ['proj_log_file'],
'level': 'DEBUG',
},
}
}
logging.config.dictConfig(LOGGING)
# Django project configuration, if environ vars are missing
#
# This is a sample file. Rename to local.env for a quick development
# settings. Git will not track local.env as it contains confidential
# information. So store a backup of this file outside this repo.
#
# Note: No spaces around '=' sign and no quotes for righthand values.
DEBUG=True
# syntax: DATABASE_URL=postgres://username:password@127.0.0.1:5432/database
DATABASE_URL=sqlite:///db.sqlite3
# Command to create a new secret key:
# $ python -c 'import random; import string; print("".join([random.SystemRandom().choice(string.digits + string.ascii_letters + string.punctuation) for i in range(100)]))'
SECRET_KEY=kc6pz7(84#l$yq=#nxl30!w()0#l6b+v457@g&8yx+byizsvx4
# In production set the environment variable like this:
# DJANGO_SETTINGS_MODULE=wugsy.settings.production
from .base import * # NOQA
import logging.config
# For security and performance reasons, DEBUG is turned off
DEBUG = False
TEMPLATE_DEBUG = False
# Must mention ALLOWED_HOSTS in production!
# ALLOWED_HOSTS = ["wugsy.com"]
# Cache the templates in memory for speed-up
loaders = [
('django.template.loaders.cached.Loader', [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]),
]
TEMPLATES[0]['OPTIONS'].update({"loaders": loaders})
TEMPLATES[0].update({"APP_DIRS": False})
# Define STATIC_ROOT for the collectstatic command
STATIC_ROOT = join(BASE_DIR, '..', 'site', 'static')
# Log everything to the logs directory at the top
LOGFILE_ROOT = join(dirname(BASE_DIR), 'logs')
# Reset logging
LOGGING_CONFIG = None
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': "[%(asctime)s] %(levelname)s [%(pathname)s:%(lineno)s] %(message)s",
'datefmt': "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'proj_log_file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': join(LOGFILE_ROOT, 'project.log'),
'formatter': 'verbose'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
}
},
'loggers': {
'project': {
'handlers': ['proj_log_file'],
'level': 'DEBUG',
},
}
}
logging.config.dictConfig(LOGGING)
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
import profiles.urls
import accounts.urls
from . import views
urlpatterns = [
url(r'^$', views.HomePage.as_view(), name='home'),
url(r'^about/$', views.AboutPage.as_view(), name='about'),
url(r'^users/', include(profiles.urls, namespace='profiles')),
url(r'^admin/', include(admin.site.urls)),
url(r'^', include(accounts.urls, namespace='accounts')),
]
# User-uploaded files like profile pics need to be served in development
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# Include django debug toolbar if DEBUG is on
if settings.DEBUG:
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
from django.views import generic
class HomePage(generic.TemplateView):
template_name = "home.html"
class AboutPage(generic.TemplateView):
template_name = "about.html"
"""
WSGI config for wugsy project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wugsy.settings.production")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Wrap werkzeug debugger if DEBUG is on
from django.conf import settings
if settings.DEBUG:
try:
import django.views.debug
import six
from werkzeug.debug import DebuggedApplication
def null_technical_500_response(request, exc_type, exc_value, tb):
six.reraise(exc_type, exc_value, tb)
django.views.debug.technical_500_response = null_technical_500_response
application = DebuggedApplication(application, evalex=True,
# Turning off pin security as DEBUG is True
pin_security=False)
except ImportError:
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment