Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of very drafty django website
- Loading branch information
1 parent
215a9f3
commit 06adf4a
Showing
95 changed files
with
12,490 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
media/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
""" | ||
Django settings for makeabilitylab project. | ||
Generated by 'django-admin startproject' using Django 1.9. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/1.9/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/1.9/ref/settings/ | ||
""" | ||
|
||
import os | ||
|
||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = 'pe)-#st8rk!pomy!_1ha7=cpypp_(8%1xqmtw%!u@kw-f5&w^e' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = [] | ||
|
||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'website.apps.WebsiteConfig', | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
# To use IPython-enabled Django shell through Django extensions | ||
# pip3 install django_extensions | ||
# python manage.py shell_plus | ||
# https://opensourcehacker.com/2014/08/13/turbocharge-your-python-prompt-and-django-shell-with-ipython-notebook/ | ||
'django_extensions' | ||
] | ||
|
||
MIDDLEWARE_CLASSES = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'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 = 'makeabilitylab.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.template.context_processors.media', | ||
'django.template.context_processors.static', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'makeabilitylab.wsgi.application' | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||
} | ||
} | ||
|
||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators | ||
|
||
AUTH_PASSWORD_VALIDATORS = [ | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
}, | ||
] | ||
|
||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/1.9/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
TIME_ZONE = 'US/Eastern' | ||
|
||
USE_I18N = True | ||
|
||
USE_L10N = True | ||
|
||
USE_TZ = True | ||
|
||
# JEF: I added these for uploading files. | ||
# See: | ||
# http://stackoverflow.com/questions/22570723/handling-uploading-image-django-admin-python | ||
# https://github.com/axelpale/minimal-django-file-upload-example | ||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | ||
MEDIA_URL = '/media/' | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/1.9/howto/static-files/ | ||
|
||
STATIC_URL = '/static/' |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""makeabilitylab URL Configuration | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/1.9/topics/http/urls/ | ||
Examples: | ||
Function views | ||
1. Add an import: from my_app import views | ||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') | ||
Class-based views | ||
1. Add an import: from other_app.views import Home | ||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') | ||
Including another URLconf | ||
1. Add an import: from blog import urls as blog_urls | ||
2. Import the include() function: from django.conf.urls import url, include | ||
3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) | ||
""" | ||
from django.conf.urls import include, url | ||
from django.contrib import admin | ||
from django.conf.urls.static import static | ||
from django.conf import settings | ||
|
||
urlpatterns = [ | ||
url(r'^website/', include('website.urls')), | ||
url(r'^admin/', admin.site.urls), | ||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for makeabilitylab 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/1.9/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "makeabilitylab.settings") | ||
|
||
application = get_wsgi_application() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "makeabilitylab.settings") | ||
|
||
from django.core.management import execute_from_command_line | ||
|
||
execute_from_command_line(sys.argv) |
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Person, Publication, Position, Talk, Project, Poster, Keyword | ||
|
||
from django.http import HttpResponse | ||
from datetime import datetime | ||
from django.template import loader | ||
from django.template import RequestContext | ||
|
||
from django.shortcuts import redirect | ||
|
||
from django import forms | ||
|
||
import urllib | ||
|
||
import bibtexparser | ||
|
||
#class ChoiceInline(admin.StackedInline): | ||
class RoleInline(admin.StackedInline): | ||
model = Position | ||
extra = 1 | ||
|
||
class PersonAdmin(admin.ModelAdmin): | ||
inlines = [RoleInline] | ||
|
||
class PublicationAdmin(admin.ModelAdmin): | ||
fieldsets = [ | ||
(None, {'fields': ['title', 'authors', 'date']}), | ||
('Pub Venue information', {'fields': ['pub_venue_type', 'book_title', 'book_title_short', 'geo_location', 'total_papers_submitted', 'total_papers_accepted']}), | ||
('Archival Info', {'fields': ['official_url', 'extended_abstract', 'peer_reviewed', 'award' ]}), | ||
('Video Info', {'fields': ['video_url', 'video_preview_url']}), | ||
('Page Info', {'fields': ['num_pages', 'page_num_start', 'page_num_end']}), | ||
('Talk Info', {'fields': ['talk']}), | ||
('Project Info', {'fields': ['projects']}), | ||
] | ||
list_display = ('title', 'book_title_short') | ||
filter_horizontal = ('authors', 'projects') | ||
|
||
# The following code is based in part on a hint by this Stackoverflow post: http://stackoverflow.com/a/4952370 | ||
# See: http://stackoverflow.com/a/10041463 for overiding admin forms | ||
def add_view(self, request, **kwargs): | ||
|
||
temp = request.GET | ||
# return redirect('/admin/website/publication/add/?title=test') | ||
if request.method == 'POST': | ||
# Stage 1 form submitted, parse data and redirect to with data in url to get Django to auto-fill in form | ||
extra_context = {} | ||
|
||
extra_context['test_var'] = 'In stage 2!' | ||
bibtex_str = request.POST['bibtex_textarea'] | ||
bib_database = bibtexparser.loads(bibtex_str) | ||
bib_entry = bib_database.entries[0] | ||
# str_items = "" | ||
# for key in bib_entry: | ||
# str_items = str_items + "{}={}&".format(key, bib_entry[key]) | ||
# | ||
# raw_url = '/admin/website/publication/add/?{}'.format(str_items) | ||
# prepared_url = urllib.parse.urlencode(raw_url) | ||
#return redirect() | ||
|
||
# TODO: The problem is that passing values in the url only works if those values are already existing | ||
# django entries. So, for example, if you pass in a bibtex that has a new, never-before-seen author | ||
# then we need to create that Author database entry first. I also cannot actually get one-to-many fields | ||
# like authors to actually pass correctly by value in the url. | ||
params = urllib.parse.urlencode(bib_entry) | ||
redirect_url = '/admin/website/publication/add/?{}'.format(params) | ||
return redirect(redirect_url) | ||
#return redirect('/admin/website/publication/add/?title="test"') | ||
|
||
elif not request.GET: | ||
|
||
opts = self.model._meta | ||
app_label = opts.app_label | ||
|
||
template = loader.get_template('admin/website/publication/bibtex_form.html') | ||
context = RequestContext(request) | ||
|
||
# because bibtex_form.thml extends the 'admin/change_form.html' template, we need to add in some variables | ||
# that change_form.html requires. See: http://stackoverflow.com/questions/28777376/problems-extend-change-form-html-in-django-admin | ||
# and specifically the answer: http://stackoverflow.com/a/28777461 | ||
context.push( | ||
{"test_var": "in stage 1", | ||
'opts': opts, | ||
'app_label': app_label, | ||
'change': False, | ||
'is_popup': False, | ||
'save_as': False, | ||
'has_delete_permission': False, | ||
'has_add_permission': False, | ||
'has_change_permission': False} | ||
) | ||
return HttpResponse(template.render(context)) | ||
elif request.GET: | ||
extra_context = {} | ||
extra_context['test_var'] = 'In stage 1' | ||
return super(PublicationAdmin, self).add_view(request, extra_context=extra_context, **kwargs) | ||
|
||
admin.site.register(Person, PersonAdmin) | ||
# admin.site.register(Member) | ||
admin.site.register(Publication, PublicationAdmin) | ||
admin.site.register(Talk) | ||
admin.site.register(Project) | ||
admin.site.register(Poster) | ||
admin.site.register(Keyword) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class WebsiteConfig(AppConfig): | ||
name = 'website' | ||
|
||
# Because we are using the decorator approach to hook up signals in the website app, we need | ||
# to import the signals submodule in the ready() function. | ||
# See: https://docs.djangoproject.com/en/1.9/topics/signals/#connecting-receiver-functions | ||
def ready(self): | ||
import website.signals |
Binary file not shown.
Oops, something went wrong.