ソースを参照

Add in some new settings.

tags/v0.4.1
Isaac Bythewood 12年前
コミット
f00e106dfe
8個のファイルの変更64行の追加5行の削除
  1. +13
    -0
      README.md
  2. +1
    -0
      pinry/core/context_processors.py
  3. +15
    -0
      pinry/core/middleware.py
  4. +18
    -0
      pinry/core/templates/core/private.html
  5. +1
    -0
      pinry/core/urls.py
  6. +6
    -2
      pinry/core/views.py
  7. +9
    -2
      pinry/settings/__init__.py
  8. +1
    -1
      pinry/settings/development.py

+ 13
- 0
README.md ファイルの表示

@@ -48,6 +48,19 @@ hundreds of different ways to deploy a Django project and everyone has their own
preference.


### Quick Settings

There are a few settings provided specific to Pinry that allow you to get some
of the most requested functionality easily.

+ **SITE_NAME**: For quickly changing the name Pinry to something you prefer.
+ **ALLOW_NEW_REGISTRATIONS**: Set to False to prevent people from registering.
+ **PUBLIC**: Set to False to require people to register before viewing pins.
(Note: Setting PUBLIC to False does still allow registrations. Make sure
both PUBLIC and the previous setting are set to False to prevent
all public access.)


## Roadmap

+ Non-image URL pinning


+ 1
- 0
pinry/core/context_processors.py ファイルの表示

@@ -5,3 +5,4 @@ def template_settings(request):
return {
'site_name': settings.SITE_NAME,
}


+ 15
- 0
pinry/core/middleware.py ファイルの表示

@@ -0,0 +1,15 @@
from django.conf import settings
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse


class Public(object):
def process_request(self, request):
if settings.PUBLIC == False and not request.user.is_authenticated():
acceptable_paths = [
'/login/',
'/private/',
'/register/',
]
if request.path not in acceptable_paths:
return HttpResponseRedirect(reverse('core:private'))

+ 18
- 0
pinry/core/templates/core/private.html ファイルの表示

@@ -0,0 +1,18 @@
{% extends 'core/base.html' %}

{% load bootstrap_field %}


{% block title %}Private{% endblock %}

{% block yield %}
<div class="container">
<div class="row">
<div id="form" class="span6 offset3">
<h1>Private</h1>
<p>This website is set to private. You need to login before you
can view any content.</p>
</div>
</div>
</div>
{% endblock %}

+ 1
- 0
pinry/core/urls.py ファイルの表示

@@ -3,6 +3,7 @@ from django.conf.urls import patterns, url

urlpatterns = patterns('',
url(r'^$', 'pinry.core.views.home', name='home'),
url(r'^private/$', 'pinry.core.views.private', name='private'),
url(r'^login/$', 'django.contrib.auth.views.login',
{'template_name': 'core/login.html'}, name='login'),
url(r'^register/$', 'pinry.core.views.register', name='register'),


+ 6
- 2
pinry/core/views.py ファイルの表示

@@ -12,10 +12,14 @@ def home(request):
return HttpResponseRedirect(reverse('pins:recent-pins'))


def private(request):
return TemplateResponse(request, 'core/private.html', None)


def register(request):
if not settings.ALLOW_NEW_REGISTRATIONS:
messages.error(request, "The admin of this service is currently not "
"allowing new users to register.")
messages.error(request, "The admin of this service is not "
"allowing new registrations.")
return HttpResponseRedirect(reverse('pins:recent-pins'))
if request.method == 'POST':
form = UserCreationForm(request.POST)


+ 9
- 2
pinry/settings/__init__.py ファイルの表示

@@ -2,11 +2,17 @@ import os
from django.contrib.messages import constants as messages


SITE_ROOT = os.path.join(os.path.realpath(os.path.dirname(__file__)), '../../')


# Changes the naming on the front-end of the website.
SITE_NAME = 'Pinry'
ALLOW_NEW_REGISTRATIONS = True

# Set to False to disable people from creating new accounts.
ALLOW_NEW_REGISTRATIONS = True

SITE_ROOT = os.path.join(os.path.realpath(os.path.dirname(__file__)), '../../')
# Set to False to force users to login before seeing any pins.
PUBLIC = True


TIME_ZONE = 'America/New_York'
@@ -34,6 +40,7 @@ MIDDLEWARE_CLASSES = (
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'pinry.core.middleware.Public',
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",


+ 1
- 1
pinry/settings/development.py ファイルの表示

@@ -13,4 +13,4 @@ DATABASES = {
}
}

SECRET_KEY = ''
SECRET_KEY = 'fake-key'

読み込み中…
キャンセル
保存