diff --git a/.gitignore b/.gitignore index 0b97582..4775b20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,11 @@ -# virtualenv /bin/ /lib/ /include/ /local -/Scripts/ - -# pip /pip-log.txt /build/ - -# django /development.db /media/ /static/ - -# python *.pyc -# jenkins -/reports/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2f365bf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: python +python: + - "2.6" + - "2.7" +# command to install dependencies +install: pip install -r requirements.txt +# command to run tests +script: python manage.py test diff --git a/README.md b/README.md index f9267d0..752265d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # ![Pinry](https://github.com/overshard/pinry/raw/master/logo.png) Pinry is a private, self-hosted, [Pinterest][0] inspired by [Wookmark][1] and -built on top of Django. +built on top of Django. Pinry is currently in Alpha/Development, some upgrades +may be ugly/not work till I release v1.0.0. ![Pinry Screenshot](https://github.com/overshard/pinry/raw/master/screenshot.png) @@ -36,38 +37,15 @@ Note: On Ubuntu you can get the build deps by running $ bin/python manage.py runserver -### Jenkins - -If you want to use Pinry with your own Jenkins server I've already setup all of -the settings on Pinry, just follow the instructions starting at section 3 on the -official [Django Jenkins Tutorial][4]. - -A quick tip, when you get to the `Add build step -> Execute shell` step instead -of using his example use: - - virtualenv --system-site-packages . - bin/pip install -r requirements/jenkins.txt - bin/python manage.py jenkins --settings=pinry.settings.jenkins - -As noted in development be sure you have PIL installed or it's build -dependencies. - ### Production If you want a production server [Google around][2] for more information on -running Django in a production environment and create a +running Django in a production environment and edit the `pinry/settings/production.py` file. I don't cover this because there are hundreds of different ways to deploy a Django project and everyone has their own preference. -## Build Status - -For build information on the latest commit head over to my [Jenkins server][3]. -You'll get useful information on if all my tests are passing, my test coverage, -and if I'm conforming with pylint and pep8 standards. - - ## Roadmap + Non-image URL pinning @@ -115,5 +93,3 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [0]: http://pinterest.com/ [1]: http://www.wookmark.com/ [2]: https://www.google.com/search?q=deploy+django+production -[3]: http://jenkins.bythewood.me/job/pinry/ -[4]: https://sites.google.com/site/kmmbvnr/home/django-jenkins-tutorial diff --git a/pinry/core/views.py b/pinry/core/views.py index e626647..3d50ee7 100644 --- a/pinry/core/views.py +++ b/pinry/core/views.py @@ -5,6 +5,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth import logout from django.contrib.auth.forms import UserCreationForm from django.contrib import messages +from django.conf import settings def home(request): @@ -12,6 +13,10 @@ def home(request): 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.") + return HttpResponseRedirect(reverse('pins:recent-pins')) if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): @@ -21,6 +26,7 @@ def register(request): return HttpResponseRedirect(reverse('core:login')) else: form = UserCreationForm() + return TemplateResponse(request, 'core/register.html', {'form': form}) diff --git a/pinry/settings/__init__.py b/pinry/settings/__init__.py index 8b920e2..d421285 100644 --- a/pinry/settings/__init__.py +++ b/pinry/settings/__init__.py @@ -3,6 +3,7 @@ from django.contrib.messages import constants as messages SITE_NAME = 'Pinry' +ALLOW_NEW_REGISTRATIONS = True SITE_ROOT = os.path.join(os.path.realpath(os.path.dirname(__file__)), '../../') @@ -46,7 +47,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ) ROOT_URLCONF = 'pinry.urls' -WSGI_APPLICATION = 'pinry.wsgi.application' LOGIN_REDIRECT_URL = '/' INTERNAL_IPS = ['127.0.0.1'] MESSAGE_TAGS = { diff --git a/pinry/settings/jenkins.py b/pinry/settings/jenkins.py deleted file mode 100644 index fac778a..0000000 --- a/pinry/settings/jenkins.py +++ /dev/null @@ -1,35 +0,0 @@ -from pinry.settings import * - -import os - - -DEBUG = True -TEMPLATE_DEBUG = DEBUG - - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(SITE_ROOT, 'development.db'), - } -} - -SECRET_KEY = '' - - -INSTALLED_APPS += ('django_jenkins',) -PROJECT_APPS = ( - 'pinry.vendor', - 'pinry.core', - 'pinry.pins', - 'pinry.api', -) - - -JENKINS_TASKS = ( - 'django_jenkins.tasks.with_coverage', - 'django_jenkins.tasks.django_tests', - 'django_jenkins.tasks.run_pylint', - 'django_jenkins.tasks.run_pep8', - 'django_jenkins.tasks.run_pyflakes', -) diff --git a/pinry/settings/production.py b/pinry/settings/production.py new file mode 100644 index 0000000..19867ce --- /dev/null +++ b/pinry/settings/production.py @@ -0,0 +1,18 @@ +from pinry.settings import * + +import os + + +DEBUG = False +TEMPLATE_DEBUG = DEBUG + +# TODO: I recommend using psycopg2 w/ postgres but sqlite3 is good enough. +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(SITE_ROOT, 'production.db'), + } +} + +# TODO: Be sure to set this. +SECRET_KEY = '' diff --git a/pinry/wsgi.py b/pinry/wsgi.py deleted file mode 100644 index 585f9e1..0000000 --- a/pinry/wsgi.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -WSGI config for pinry project. - -This module contains the WSGI application used by Django's development server -and any production WSGI deployments. It should expose a module-level variable -named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover -this application via the ``WSGI_APPLICATION`` setting. - -Usually you will have the standard Django WSGI application here, but it also -might make sense to replace the whole Django WSGI application with a custom one -that later delegates to the Django one. For example, you could introduce WSGI -middleware here, or combine a Django application with an application of another -framework. - -""" -import os - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings") - -# This application object is used by any WSGI server configured to use this -# file. This includes Django's development server, if the WSGI_APPLICATION -# setting points here. -from django.core.wsgi import get_wsgi_application -application = get_wsgi_application() - -# Apply WSGI middleware here. -# from helloworld.wsgi import HelloWorldApplication -# application = HelloWorldApplication(application) diff --git a/requirements/include.txt b/requirements.txt similarity index 100% rename from requirements/include.txt rename to requirements.txt diff --git a/requirements/development.txt b/requirements/development.txt deleted file mode 100644 index 617e574..0000000 --- a/requirements/development.txt +++ /dev/null @@ -1,2 +0,0 @@ --r include.txt - diff --git a/requirements/jenkins.txt b/requirements/jenkins.txt deleted file mode 100644 index 0e019fe..0000000 --- a/requirements/jenkins.txt +++ /dev/null @@ -1,8 +0,0 @@ --r include.txt - -django-jenkins==0.12.1 -coverage==3.5.2 -pylint==0.25.1 -pep8==1.0.1 -pyflakes==0.5.0 - diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..50fb75a --- /dev/null +++ b/wsgi.py @@ -0,0 +1,8 @@ +import os + + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings.production") + + +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application()