diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9af8fd1 Binary files /dev/null and b/.DS_Store differ diff --git a/.direnv/python-3.4.3/bin/activate b/.direnv/python-3.4.3/bin/activate new file mode 100644 index 0000000..6a0be89 --- /dev/null +++ b/.direnv/python-3.4.3/bin/activate @@ -0,0 +1,80 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + unset pydoc + + # reset old environment variables + if [ -n "$_OLD_VIRTUAL_PATH" ] ; then + PATH="$_OLD_VIRTUAL_PATH" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then + PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then + hash -r 2>/dev/null + fi + + if [ -n "$_OLD_VIRTUAL_PS1" ] ; then + PS1="$_OLD_VIRTUAL_PS1" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + if [ ! "$1" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +# unset PYTHONHOME if set +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) +# could use `if (set -u; : $PYTHONHOME) ;` in bash +if [ -n "$PYTHONHOME" ] ; then + _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" + unset PYTHONHOME +fi + +if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then + _OLD_VIRTUAL_PS1="$PS1" + if [ "x" != x ] ; then + PS1="$PS1" + else + if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then + # special case for Aspen magic directories + # see http://www.zetadev.com/software/aspen/ + PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" + else + PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" + fi + fi + export PS1 +fi + +alias pydoc="python -m pydoc" + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then + hash -r 2>/dev/null +fi diff --git a/.direnv/python-3.4.3/bin/activate.csh b/.direnv/python-3.4.3/bin/activate.csh new file mode 100644 index 0000000..48a4613 --- /dev/null +++ b/.direnv/python-3.4.3/bin/activate.csh @@ -0,0 +1,42 @@ +# This file must be used with "source bin/activate.csh" *from csh*. +# You cannot run it directly. +# Created by Davide Di Blasi . + +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc' + +# Unset irrelevant variables. +deactivate nondestructive + +setenv VIRTUAL_ENV "/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3" + +set _OLD_VIRTUAL_PATH="$PATH" +setenv PATH "$VIRTUAL_ENV/bin:$PATH" + + + +if ("" != "") then + set env_name = "" +else + if (`basename "$VIRTUAL_ENV"` == "__") then + # special case for Aspen magic directories + # see http://www.zetadev.com/software/aspen/ + set env_name = `basename \`dirname "$VIRTUAL_ENV"\`` + else + set env_name = `basename "$VIRTUAL_ENV"` + endif +endif + +# Could be in a non-interactive environment, +# in which case, $prompt is undefined and we wouldn't +# care about the prompt anyway. +if ( $?prompt ) then + set _OLD_VIRTUAL_PROMPT="$prompt" + set prompt = "[$env_name] $prompt" +endif + +unset env_name + +alias pydoc python -m pydoc + +rehash + diff --git a/.direnv/python-3.4.3/bin/activate.fish b/.direnv/python-3.4.3/bin/activate.fish new file mode 100644 index 0000000..79a461d --- /dev/null +++ b/.direnv/python-3.4.3/bin/activate.fish @@ -0,0 +1,74 @@ +# This file must be used with "source bin/activate.fish" *from fish* (http://fishshell.com) +# you cannot run it directly + +function deactivate -d "Exit virtualenv and return to normal shell environment" + # reset old environment variables + if test -n "$_OLD_VIRTUAL_PATH" + set -gx PATH $_OLD_VIRTUAL_PATH + set -e _OLD_VIRTUAL_PATH + end + if test -n "$_OLD_VIRTUAL_PYTHONHOME" + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME + set -e _OLD_VIRTUAL_PYTHONHOME + end + + if test -n "$_OLD_FISH_PROMPT_OVERRIDE" + # set an empty local fish_function_path, so fish_prompt doesn't automatically reload + set -l fish_function_path + # erase the virtualenv's fish_prompt function, and restore the original + functions -e fish_prompt + functions -c _old_fish_prompt fish_prompt + functions -e _old_fish_prompt + set -e _OLD_FISH_PROMPT_OVERRIDE + end + + set -e VIRTUAL_ENV + if test "$argv[1]" != "nondestructive" + # Self destruct! + functions -e deactivate + end +end + +# unset irrelevant variables +deactivate nondestructive + +set -gx VIRTUAL_ENV "/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3" + +set -gx _OLD_VIRTUAL_PATH $PATH +set -gx PATH "$VIRTUAL_ENV/bin" $PATH + +# unset PYTHONHOME if set +if set -q PYTHONHOME + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME + set -e PYTHONHOME +end + +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" + # fish uses a function instead of an env var to generate the prompt. + + # copy the current fish_prompt function as the function _old_fish_prompt + functions -c fish_prompt _old_fish_prompt + + # with the original prompt function copied, we can override with our own. + function fish_prompt + # Prompt override? + if test -n "" + printf "%s%s" "" (set_color normal) + _old_fish_prompt + return + end + # ...Otherwise, prepend env + set -l _checkbase (basename "$VIRTUAL_ENV") + if test $_checkbase = "__" + # special case for Aspen magic directories + # see http://www.zetadev.com/software/aspen/ + printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal) + _old_fish_prompt + else + printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal) + _old_fish_prompt + end + end + + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" +end diff --git a/.direnv/python-3.4.3/bin/activate_this.py b/.direnv/python-3.4.3/bin/activate_this.py new file mode 100644 index 0000000..f18193b --- /dev/null +++ b/.direnv/python-3.4.3/bin/activate_this.py @@ -0,0 +1,34 @@ +"""By using execfile(this_file, dict(__file__=this_file)) you will +activate this virtualenv environment. + +This can be used when you must use an existing Python interpreter, not +the virtualenv bin/python +""" + +try: + __file__ +except NameError: + raise AssertionError( + "You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))") +import sys +import os + +old_os_path = os.environ.get('PATH', '') +os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path +base = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +if sys.platform == 'win32': + site_packages = os.path.join(base, 'Lib', 'site-packages') +else: + site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages') +prev_sys_path = list(sys.path) +import site +site.addsitedir(site_packages) +sys.real_prefix = sys.prefix +sys.prefix = base +# Move the added items to the front of the path: +new_sys_path = [] +for item in list(sys.path): + if item not in prev_sys_path: + new_sys_path.append(item) + sys.path.remove(item) +sys.path[:0] = new_sys_path diff --git a/.direnv/python-3.4.3/bin/django-admin b/.direnv/python-3.4.3/bin/django-admin new file mode 100755 index 0000000..76821ee --- /dev/null +++ b/.direnv/python-3.4.3/bin/django-admin @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python3.4 + +# -*- coding: utf-8 -*- +import re +import sys + +from django.core.management import execute_from_command_line + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(execute_from_command_line()) diff --git a/.direnv/python-3.4.3/bin/django-admin.py b/.direnv/python-3.4.3/bin/django-admin.py new file mode 100755 index 0000000..1b92898 --- /dev/null +++ b/.direnv/python-3.4.3/bin/django-admin.py @@ -0,0 +1,5 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python3.4 +from django.core import management + +if __name__ == "__main__": + management.execute_from_command_line() diff --git a/.direnv/python-3.4.3/bin/easy_install b/.direnv/python-3.4.3/bin/easy_install new file mode 100755 index 0000000..c989acc --- /dev/null +++ b/.direnv/python-3.4.3/bin/easy_install @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python3.4 + +# -*- coding: utf-8 -*- +import re +import sys + +from setuptools.command.easy_install import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.direnv/python-3.4.3/bin/easy_install-3.4 b/.direnv/python-3.4.3/bin/easy_install-3.4 new file mode 100755 index 0000000..c989acc --- /dev/null +++ b/.direnv/python-3.4.3/bin/easy_install-3.4 @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python3.4 + +# -*- coding: utf-8 -*- +import re +import sys + +from setuptools.command.easy_install import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.direnv/python-3.4.3/bin/f2py b/.direnv/python-3.4.3/bin/f2py new file mode 100755 index 0000000..3157387 --- /dev/null +++ b/.direnv/python-3.4.3/bin/f2py @@ -0,0 +1,24 @@ +#!/Users/travis/build/MacPython/numpy-wheels/venv/bin/python +# See http://cens.ioc.ee/projects/f2py2e/ +import os, sys +for mode in ["g3-numpy", "2e-numeric", "2e-numarray", "2e-numpy"]: + try: + i=sys.argv.index("--"+mode) + del sys.argv[i] + break + except ValueError: pass +os.environ["NO_SCIPY_IMPORT"]="f2py" +if mode=="g3-numpy": + sys.stderr.write("G3 f2py support is not implemented, yet.\n") + sys.exit(1) +elif mode=="2e-numeric": + from f2py2e import main +elif mode=="2e-numarray": + sys.argv.append("-DNUMARRAY") + from f2py2e import main +elif mode=="2e-numpy": + from numpy.f2py import main +else: + sys.stderr.write("Unknown mode: " + repr(mode) + "\n") + sys.exit(1) +main() diff --git a/.direnv/python-3.4.3/bin/faker b/.direnv/python-3.4.3/bin/faker new file mode 100755 index 0000000..e981d9f --- /dev/null +++ b/.direnv/python-3.4.3/bin/faker @@ -0,0 +1,7 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python +# coding=utf-8 + +from faker.cli import execute_from_command_line + +if __name__ == '__main__': + execute_from_command_line() diff --git a/.direnv/python-3.4.3/bin/ipcluster b/.direnv/python-3.4.3/bin/ipcluster new file mode 100755 index 0000000..daa9d81 --- /dev/null +++ b/.direnv/python-3.4.3/bin/ipcluster @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython.parallel.apps.ipclusterapp import launch_new_instance + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(launch_new_instance()) diff --git a/.direnv/python-3.4.3/bin/ipcluster3 b/.direnv/python-3.4.3/bin/ipcluster3 new file mode 100755 index 0000000..daa9d81 --- /dev/null +++ b/.direnv/python-3.4.3/bin/ipcluster3 @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython.parallel.apps.ipclusterapp import launch_new_instance + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(launch_new_instance()) diff --git a/.direnv/python-3.4.3/bin/ipcontroller b/.direnv/python-3.4.3/bin/ipcontroller new file mode 100755 index 0000000..2a9a914 --- /dev/null +++ b/.direnv/python-3.4.3/bin/ipcontroller @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython.parallel.apps.ipcontrollerapp import launch_new_instance + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(launch_new_instance()) diff --git a/.direnv/python-3.4.3/bin/ipcontroller3 b/.direnv/python-3.4.3/bin/ipcontroller3 new file mode 100755 index 0000000..2a9a914 --- /dev/null +++ b/.direnv/python-3.4.3/bin/ipcontroller3 @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython.parallel.apps.ipcontrollerapp import launch_new_instance + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(launch_new_instance()) diff --git a/.direnv/python-3.4.3/bin/ipengine b/.direnv/python-3.4.3/bin/ipengine new file mode 100755 index 0000000..ff06c16 --- /dev/null +++ b/.direnv/python-3.4.3/bin/ipengine @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython.parallel.apps.ipengineapp import launch_new_instance + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(launch_new_instance()) diff --git a/.direnv/python-3.4.3/bin/ipengine3 b/.direnv/python-3.4.3/bin/ipengine3 new file mode 100755 index 0000000..ff06c16 --- /dev/null +++ b/.direnv/python-3.4.3/bin/ipengine3 @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython.parallel.apps.ipengineapp import launch_new_instance + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(launch_new_instance()) diff --git a/.direnv/python-3.4.3/bin/iptest b/.direnv/python-3.4.3/bin/iptest new file mode 100755 index 0000000..fb5183f --- /dev/null +++ b/.direnv/python-3.4.3/bin/iptest @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython.testing.iptestcontroller import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.direnv/python-3.4.3/bin/iptest3 b/.direnv/python-3.4.3/bin/iptest3 new file mode 100755 index 0000000..fb5183f --- /dev/null +++ b/.direnv/python-3.4.3/bin/iptest3 @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython.testing.iptestcontroller import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.direnv/python-3.4.3/bin/ipython b/.direnv/python-3.4.3/bin/ipython new file mode 100755 index 0000000..8448aa6 --- /dev/null +++ b/.direnv/python-3.4.3/bin/ipython @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython import start_ipython + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(start_ipython()) diff --git a/.direnv/python-3.4.3/bin/ipython3 b/.direnv/python-3.4.3/bin/ipython3 new file mode 100755 index 0000000..8448aa6 --- /dev/null +++ b/.direnv/python-3.4.3/bin/ipython3 @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from IPython import start_ipython + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(start_ipython()) diff --git a/.direnv/python-3.4.3/bin/pip b/.direnv/python-3.4.3/bin/pip new file mode 100755 index 0000000..e87459a --- /dev/null +++ b/.direnv/python-3.4.3/bin/pip @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python3.4 + +# -*- coding: utf-8 -*- +import re +import sys + +from pip import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.direnv/python-3.4.3/bin/pip3 b/.direnv/python-3.4.3/bin/pip3 new file mode 100755 index 0000000..e87459a --- /dev/null +++ b/.direnv/python-3.4.3/bin/pip3 @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python3.4 + +# -*- coding: utf-8 -*- +import re +import sys + +from pip import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.direnv/python-3.4.3/bin/pip3.4 b/.direnv/python-3.4.3/bin/pip3.4 new file mode 100755 index 0000000..e87459a --- /dev/null +++ b/.direnv/python-3.4.3/bin/pip3.4 @@ -0,0 +1,11 @@ +#!/Users/briandeshazer/tiy/django-movies/.direnv/python-3.4.3/bin/python3.4 + +# -*- coding: utf-8 -*- +import re +import sys + +from pip import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.direnv/python-3.4.3/bin/python b/.direnv/python-3.4.3/bin/python new file mode 120000 index 0000000..bdceba4 --- /dev/null +++ b/.direnv/python-3.4.3/bin/python @@ -0,0 +1 @@ +python3.4 \ No newline at end of file diff --git a/.direnv/python-3.4.3/bin/python3 b/.direnv/python-3.4.3/bin/python3 new file mode 120000 index 0000000..bdceba4 --- /dev/null +++ b/.direnv/python-3.4.3/bin/python3 @@ -0,0 +1 @@ +python3.4 \ No newline at end of file diff --git a/.direnv/python-3.4.3/bin/python3.4 b/.direnv/python-3.4.3/bin/python3.4 new file mode 100755 index 0000000..ccc813e Binary files /dev/null and b/.direnv/python-3.4.3/bin/python3.4 differ diff --git a/.direnv/python-3.4.3/include/python3.4m b/.direnv/python-3.4.3/include/python3.4m new file mode 120000 index 0000000..b1d022a --- /dev/null +++ b/.direnv/python-3.4.3/include/python3.4m @@ -0,0 +1 @@ +/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m \ No newline at end of file diff --git a/.direnv/python-3.4.3/pip-selfcheck.json b/.direnv/python-3.4.3/pip-selfcheck.json new file mode 100644 index 0000000..0e8e730 --- /dev/null +++ b/.direnv/python-3.4.3/pip-selfcheck.json @@ -0,0 +1 @@ +{"last_check":"2015-06-09T17:45:44Z","pypi_version":"7.0.3"} \ No newline at end of file diff --git a/.direnv/python-3.4.3/share/man/man1/ipcluster.1.gz b/.direnv/python-3.4.3/share/man/man1/ipcluster.1.gz new file mode 100644 index 0000000..30f4361 Binary files /dev/null and b/.direnv/python-3.4.3/share/man/man1/ipcluster.1.gz differ diff --git a/.direnv/python-3.4.3/share/man/man1/ipcontroller.1.gz b/.direnv/python-3.4.3/share/man/man1/ipcontroller.1.gz new file mode 100644 index 0000000..3b5f03d Binary files /dev/null and b/.direnv/python-3.4.3/share/man/man1/ipcontroller.1.gz differ diff --git a/.direnv/python-3.4.3/share/man/man1/ipengine.1.gz b/.direnv/python-3.4.3/share/man/man1/ipengine.1.gz new file mode 100644 index 0000000..5c597cc Binary files /dev/null and b/.direnv/python-3.4.3/share/man/man1/ipengine.1.gz differ diff --git a/.direnv/python-3.4.3/share/man/man1/ipython.1.gz b/.direnv/python-3.4.3/share/man/man1/ipython.1.gz new file mode 100644 index 0000000..c3029f8 Binary files /dev/null and b/.direnv/python-3.4.3/share/man/man1/ipython.1.gz differ diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..94840b3 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +layout python3 diff --git a/.gitignore b/.gitignore index 56c4f0f..655b903 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,9 @@ target/ data/ *.sqlite *.sqlite3 + +.DS_Store +.envrc +.direnv + +.idea/ \ No newline at end of file diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..860ebf6 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +django-movies \ No newline at end of file diff --git a/.idea/django-movies.iml b/.idea/django-movies.iml new file mode 100644 index 0000000..83cf5ac --- /dev/null +++ b/.idea/django-movies.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e17a870 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5e77400 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..2061dd8 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,693 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1433870992512 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/django-movies/.gitignore b/django-movies/.gitignore new file mode 100644 index 0000000..cc9c365 --- /dev/null +++ b/django-movies/.gitignore @@ -0,0 +1,68 @@ +# Created by https://www.gitignore.io + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +data/ +*.sqlite +*.sqlite3 + +data + +movieratings/fixtures \ No newline at end of file diff --git a/README.md b/django-movies/README.md similarity index 100% rename from README.md rename to django-movies/README.md diff --git a/django-movies/convert_ml_1m_data.py b/django-movies/convert_ml_1m_data.py new file mode 100755 index 0000000..519ffbd --- /dev/null +++ b/django-movies/convert_ml_1m_data.py @@ -0,0 +1,77 @@ +import csv +import json +from datetime import date + +print("Converting users...") +users = [] +with open("data/users.dat") as infile: + reader = csv.reader((line.replace("::", "_") for line in infile), + delimiter="_") + for row in reader: + users.append({"model": "movies.Rater", + "pk": row[0], + "fields": { + "age": row[2], + "gender": row[1], + "zipcode": row[4] + }}) + +with open("movieratings/fixtures/users.json", "w") as outfile: + outfile.write(json.dumps(users)) + + +print("Converting genres...") +genres = set() +genre_list = [] +genre_dict = {} +with open("data/movies.dat", encoding="windows-1252") as infile: + reader = csv.reader((line.replace("::", "_") for line in infile), + delimiter="_") + for row in reader: + genres.update(row[2].split("|")) + for idx, genre in enumerate(sorted(genres)): + genre_dict[genre] = idx + for genre, idx in genre_dict.items(): + genre_list.append({"model": "movies.Genre", + "pk": idx + 1, + "fields": { + "name": genre + }}) + +with open("movieratings/fixtures/genres.json", "w") as outfile: + outfile.write(json.dumps(genre_list)) + +print("Converting movies...") +movies = [] +with open("data/movies.dat", encoding="windows-1252") as infile: + reader = csv.reader((line.replace("::", "_") for line in infile), + delimiter="_") + for row in reader: + movies.append({"model": "movies.Movie", + "pk": row[0], + "fields": { + "title": row[1], + "genre": [genre_dict[genre]+1 for genre in row[2].split("|")] + }}) + +with open("movieratings/fixtures/movies.json", "w") as outfile: + outfile.write(json.dumps(movies)) + +print("Converting ratings...") +ratings = [] +with open("data/ratings.dat") as infile: + reader = csv.reader((line.replace("::", "_") for line in infile), + delimiter="_") + for idx, row in enumerate(reader): + date2 = date.fromtimestamp(int(row[3])).__str__() + ratings.append({"model": "movies.Rating", + "pk": idx + 1, + "fields": { + "userid": row[0], + "movieid": row[1], + "rating": row[2], + "date": date2 + }}) + +with open("movieratings/fixtures/ratings.json", "w") as outfile: + outfile.write(json.dumps(ratings)) diff --git a/movieratings/manage.py b/django-movies/movieratings/manage.py similarity index 100% rename from movieratings/manage.py rename to django-movies/movieratings/manage.py diff --git a/movieratings/movieratings/__init__.py b/django-movies/movieratings/movieratings/__init__.py similarity index 100% rename from movieratings/movieratings/__init__.py rename to django-movies/movieratings/movieratings/__init__.py diff --git a/movieratings/movieratings/settings.py b/django-movies/movieratings/movieratings/settings.py similarity index 96% rename from movieratings/movieratings/settings.py rename to django-movies/movieratings/movieratings/settings.py index 3a2aaaa..8cc2624 100644 --- a/movieratings/movieratings/settings.py +++ b/django-movies/movieratings/movieratings/settings.py @@ -37,6 +37,8 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'movies', + 'bootstrap3', ) MIDDLEWARE_CLASSES = ( @@ -55,7 +57,7 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': ['templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -100,3 +102,5 @@ # https://docs.djangoproject.com/en/1.8/howto/static-files/ STATIC_URL = '/static/' + +STATICFILES_DIRS = ('static',) diff --git a/movieratings/movieratings/urls.py b/django-movies/movieratings/movieratings/urls.py similarity index 59% rename from movieratings/movieratings/urls.py rename to django-movies/movieratings/movieratings/urls.py index 656f42f..05355ab 100644 --- a/movieratings/movieratings/urls.py +++ b/django-movies/movieratings/movieratings/urls.py @@ -1,4 +1,4 @@ -"""movieratings URL Configuration +"""moviemovies URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.8/topics/http/urls/ @@ -13,9 +13,12 @@ 1. Add an import: from blog import urls as blog_urls 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ -from django.conf.urls import include, url +from django.conf.urls import include, url, patterns from django.contrib import admin +from django.views.generic import RedirectView -urlpatterns = [ - url(r'^admin/', include(admin.site.urls)), -] +urlpatterns = patterns('', + url(r'^admin/', include(admin.site.urls)), + url(r'^movies/', include('movies.urls')), + url(r'^.*$', RedirectView.as_view(url='/movies/index/', permanent=False), name='index') + ) diff --git a/movieratings/movieratings/wsgi.py b/django-movies/movieratings/movieratings/wsgi.py similarity index 100% rename from movieratings/movieratings/wsgi.py rename to django-movies/movieratings/movieratings/wsgi.py diff --git a/django-movies/movieratings/movies/__init__.py b/django-movies/movieratings/movies/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django-movies/movieratings/movies/admin.py b/django-movies/movieratings/movies/admin.py new file mode 100644 index 0000000..1e683ea --- /dev/null +++ b/django-movies/movieratings/movies/admin.py @@ -0,0 +1,17 @@ +from django.contrib import admin +from .models import Movie, Rating, Rater + +class MovieAdmin(admin.ModelAdmin): + list_display = ['id', 'title', 'get_genres'] + +class RatingsAdmin(admin.ModelAdmin): + list_display = ['movieid', 'userid', 'rating', 'date'] + +class RaterAdmin(admin.ModelAdmin): + list_display = ['id', 'age', 'gender'] + +# Register your models here. + +admin.site.register(Movie, MovieAdmin) +admin.site.register(Rating, RatingsAdmin) +admin.site.register(Rater, RaterAdmin) \ No newline at end of file diff --git a/django-movies/movieratings/movies/forms.py b/django-movies/movieratings/movies/forms.py new file mode 100644 index 0000000..42f0cc8 --- /dev/null +++ b/django-movies/movieratings/movies/forms.py @@ -0,0 +1,24 @@ +from django import forms +from django.contrib.auth.models import User +from movies.models import Rater, Rating + + +class UserForm(forms.ModelForm): + password = forms.CharField(widget=forms.PasswordInput()) + + class Meta: + model = User + fields = ('username', 'email', 'password',) + +class ProfileForm(forms.ModelForm): + class Meta: + model = Rater + fields = ('age', 'gender', 'zipcode',) + +class NewRatingForm(forms.ModelForm): + rating = forms.ChoiceField(choices=((1,1), (2,2), (3,3), (4,4), (5,5))) + review = forms.Textarea() + + class Meta: + model = Rating + fields = ('movieid', 'rating', 'review') diff --git a/django-movies/movieratings/movies/migrations/0001_initial.py b/django-movies/movieratings/movies/migrations/0001_initial.py new file mode 100644 index 0000000..5f22945 --- /dev/null +++ b/django-movies/movieratings/movies/migrations/0001_initial.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.utils.timezone +from django.conf import settings +import movies.models + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Genre', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ], + ), + migrations.CreateModel( + name='Movie', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('title', models.CharField(max_length=255)), + ('genre', models.ManyToManyField(to='movies.Genre')), + ], + ), + migrations.CreateModel( + name='Rater', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('age', models.IntegerField()), + ('gender', models.CharField(max_length=1)), + ('zipcode', models.CharField(max_length=10)), + ('user', models.OneToOneField(null=True, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Rating', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('rating', models.IntegerField(validators=[movies.models.validate_rating])), + ('date', models.DateTimeField(default=django.utils.timezone.now)), + ('review', models.TextField(null=True, blank=True)), + ('movieid', models.ForeignKey(to='movies.Movie')), + ('userid', models.ForeignKey(to='movies.Rater')), + ], + ), + ] diff --git a/django-movies/movieratings/movies/migrations/__init__.py b/django-movies/movieratings/movies/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django-movies/movieratings/movies/models.py b/django-movies/movieratings/movies/models.py new file mode 100644 index 0000000..0649d04 --- /dev/null +++ b/django-movies/movieratings/movies/models.py @@ -0,0 +1,57 @@ +from django.contrib.auth.models import User +from django.db import models +from django.utils import timezone +from django.core.exceptions import ValidationError + + + +class Genre(models.Model): + name = models.CharField(max_length=255) + + +class Movie(models.Model): + title = models.CharField(max_length=255) + #raters = models.ManyToManyField(Rater, through="Rating") + genre = models.ManyToManyField(Genre) + movies = models.Manager() + + def __str__(self): + return "{}: {}".format(self.id, self.title) + + @property + def get_genres(self): + return [the_genre.name for the_genre in self.genre.all()] + + +class Rater(models.Model): + age = models.IntegerField() + gender = models.CharField(max_length=1) + zipcode = models.CharField(max_length=10) + user = models.OneToOneField(User, null=True) + raters = models.Manager() + + def __str__(self): + return "{}".format(self.id) + +def validate_rating(value): + if 0 < value < 6: + pass + else: + raise ValidationError('{} is not a valid rating'.format(value)) + +class Rating(models.Model): + userid = models.ForeignKey(Rater) + movieid = models.ForeignKey(Movie) + rating = models.IntegerField(validators=[validate_rating]) + date = models.DateTimeField(default=timezone.now) + review = models.TextField(null=True, blank=True) + ratings = models.Manager() + + +def create_users(): + for rater in Rater.raters.all(): + user = User.objects.create_user(username='{}'.format(rater.id), email='{}@emailaddress.net'.format(rater.id), password='password') + rater.user = user + rater.save() + + diff --git a/django-movies/movieratings/movies/templates/base.html b/django-movies/movieratings/movies/templates/base.html new file mode 100644 index 0000000..948587b --- /dev/null +++ b/django-movies/movieratings/movies/templates/base.html @@ -0,0 +1,45 @@ + +{% load staticfiles %} + + + + + + + {% if request.user.is_authenticated %} +

User {{ request.user.get_username }}

+ Logout + {% else %} + Login | + Register + {% endif %} + + + + +
+ {% if messages %} + + {% endif %} +
+
+

Movie Ratings

+
+{% block content %} +{% endblock %} + + + + \ No newline at end of file diff --git a/django-movies/movieratings/movies/templates/movies/clapper.jpeg b/django-movies/movieratings/movies/templates/movies/clapper.jpeg new file mode 100644 index 0000000..04f6657 Binary files /dev/null and b/django-movies/movieratings/movies/templates/movies/clapper.jpeg differ diff --git a/django-movies/movieratings/movies/templates/movies/freq_rated.html b/django-movies/movieratings/movies/templates/movies/freq_rated.html new file mode 100644 index 0000000..7c0f78d --- /dev/null +++ b/django-movies/movieratings/movies/templates/movies/freq_rated.html @@ -0,0 +1,38 @@ +{% extends "movies/base.html" %} + +{% block content %} +

Most Frequently Rated Movies

+

Genres

+

Top Movies

+ +
+ + + + + {% if request.user.is_authenticated %} + + {% for tup in top_movies %} + + + + {% if tup.1 %} + + {% else %} + + {% endif %} + + {% endfor %} + {% else %} + {% for mov in top_movies %} + + + + + {% endfor %} + {% endif %} +
MovieNumber of RatingsSeen
{{ tup.0.title }}{{ tup.0.rating_count }}Seen ItCheck It Out
{{ mov.title }}{{ mov.rating_count }}
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/django-movies/movieratings/movies/templates/movies/index.html b/django-movies/movieratings/movies/templates/movies/index.html new file mode 100644 index 0000000..dced949 --- /dev/null +++ b/django-movies/movieratings/movies/templates/movies/index.html @@ -0,0 +1,40 @@ +{% extends "base.html" %} +{% load bootstrap3 %} +{% load staticfiles %} + +{% block content %} +

Top Movies

+

Genres

+

Most Frequently Rated

+ +
+ + + + + {% if request.user.is_authenticated %} + + {% for tup in top_movies %} + + + + {% if tup.1 %} + + {% else %} + + {% endif %} + + {% endfor %} + {% else %} + {% for mov in top_movies %} + + + + + {% endfor %} + {% endif %} +
MovieRatingSeen
{{ tup.0.title }}{{ tup.0.avg_rating|floatformat:"2" }}Seen ItCheck It Out
{{ mov.title }}{{ mov.avg_rating|floatformat:"2" }}
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/django-movies/movieratings/movies/templates/movies/login.html b/django-movies/movieratings/movies/templates/movies/login.html new file mode 100644 index 0000000..d6dcbd8 --- /dev/null +++ b/django-movies/movieratings/movies/templates/movies/login.html @@ -0,0 +1,38 @@ +{% extends "movies/base.html" %} + +{% block content %} + +{% if form.errors %} +

Your username and password didn't match. Please try again.

+{% endif %} + +{% if next %} + {% if user.is_authenticated %} +

Your account doesn't have access to this page. To proceed, + please login with an account that has access.

+ {% else %} +

Please login to see this page.

+ {% endif %} +{% endif %} + +
+{% csrf_token %} + + + + + + + + + +
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
+
+ + +
+ +{# Assumes you setup the password_reset view in your URLconf #} +{#

Lost password?

#} + +{% endblock %} \ No newline at end of file diff --git a/django-movies/movieratings/movies/templates/movies/logout.html b/django-movies/movieratings/movies/templates/movies/logout.html new file mode 100644 index 0000000..e69de29 diff --git a/django-movies/movieratings/movies/templates/movies/rate_movie.html b/django-movies/movieratings/movies/templates/movies/rate_movie.html new file mode 100644 index 0000000..fe0b9ea --- /dev/null +++ b/django-movies/movieratings/movies/templates/movies/rate_movie.html @@ -0,0 +1,20 @@ +{% extends "movies/base.html" %} +{% load bootstrap3 %} +{% bootstrap_css %} +{% bootstrap_javascript %} +{% bootstrap_messages %} + + +{% block content %} + + +

Rate Movie

+ +
+ {% csrf_token %} + {{ rate_form.as_p }} + + + +
+{% endblock %} diff --git a/django-movies/movieratings/movies/templates/movies/register.html b/django-movies/movieratings/movies/templates/movies/register.html new file mode 100644 index 0000000..03b3262 --- /dev/null +++ b/django-movies/movieratings/movies/templates/movies/register.html @@ -0,0 +1,14 @@ +{% extends "movies/base.html" %} + +{% block content %} +

Register

+ +
+ {% csrf_token %} + {{ user_form.as_p }} + {{ profile_form.as_p }} + + + +
+{% endblock %} \ No newline at end of file diff --git a/django-movies/movieratings/movies/templates/movies/show_genre.html b/django-movies/movieratings/movies/templates/movies/show_genre.html new file mode 100644 index 0000000..70a2c38 --- /dev/null +++ b/django-movies/movieratings/movies/templates/movies/show_genre.html @@ -0,0 +1,36 @@ +{% extends "movies/base.html" %} + +{% block content %} +

Top Movies in {{ genre }}

+ +
+ + + + + {% if request.user.is_authenticated %} + + {% for tup in top_movies %} + + + + {% if tup.1 %} + + {% else %} + + {% endif %} + + {% endfor %} + {% else %} + {% for mov in top_movies %} + + + + + {% endfor %} + {% endif %} +
MovieAverage RatingSeen
{{ tup.0.title }}{{ tup.0.avg_rating|floatformat:"2" }}Seen ItCheck It Out
{{ mov.title }}{{ mov.avg_rating|floatformat:"2" }}
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/django-movies/movieratings/movies/templates/movies/show_genres.html b/django-movies/movieratings/movies/templates/movies/show_genres.html new file mode 100644 index 0000000..05cf0a4 --- /dev/null +++ b/django-movies/movieratings/movies/templates/movies/show_genres.html @@ -0,0 +1,13 @@ +{% extends "movies/base.html" %} + +{% block content %} +

Genres

+ +
+ {% for genre in genres %} +

{{ genre.name }}

+ {% endfor %} + +
+ +{% endblock %} \ No newline at end of file diff --git a/django-movies/movieratings/movies/templates/movies/show_movie.html b/django-movies/movieratings/movies/templates/movies/show_movie.html new file mode 100644 index 0000000..67d499d --- /dev/null +++ b/django-movies/movieratings/movies/templates/movies/show_movie.html @@ -0,0 +1,32 @@ +{% extends "movies/base.html" %} + +{% block content %} +

{{ movie.title }}

+

Genres: {% for genre in genres %} + {{ genre }} | + {% endfor %} + +

+ +
+ {% if rate %} + Rate This Movie + {% else %} +

You rated this movie: {{ user_rating }}

+ Change Your Rating + {% endif %} +

Average Rating: {{ average|floatformat:"2" }}

+ + + + {% for tup in ratings %} + + + + + {% endfor %} +
UserRating
{{ tup.1.user.username }}{{ tup.0 }}
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/django-movies/movieratings/movies/templates/movies/show_user.html b/django-movies/movieratings/movies/templates/movies/show_user.html new file mode 100644 index 0000000..c159f64 --- /dev/null +++ b/django-movies/movieratings/movies/templates/movies/show_user.html @@ -0,0 +1,36 @@ +{% extends "movies/base.html" %} + +{% block content %} +

User {{ user }}

+ +
+

+ Username: {{ username }}
+ Age: {{ age }}
+ Gender: {{ gender }}
+ Zip Code: {{ zipcode }}
+ Average Rating: {{ average|floatformat:"2" }} +

+ + {% if average > 0 %} + + + + {% if request.user.is_authenticated %} + + {% endif %} + {% for tup in ratings %} + + + + {% if request.user.is_authenticated %} + + {% endif %} + + {% endfor %} +
MovieRatingAction
{{ tup.1.title }}{{ tup.0 }}Edit | Delete
+ {% endif %} + +
+ +{% endblock %} \ No newline at end of file diff --git a/django-movies/movieratings/movies/tests.py b/django-movies/movieratings/movies/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/django-movies/movieratings/movies/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django-movies/movieratings/movies/urls.py b/django-movies/movieratings/movies/urls.py new file mode 100644 index 0000000..828b19d --- /dev/null +++ b/django-movies/movieratings/movies/urls.py @@ -0,0 +1,19 @@ +from django.conf.urls import url, patterns +from movies import views + +urlpatterns = patterns('', + url(r'^', views.index, name='index'), + url(r'index/', views.index, name="index"), + url(r'^user/(?P\d+)$', views.show_user, name="show_user"), + url(r'^rating/(?P\d+)$', views.show_rating, name="show_rating"), + url(r'^rate/(?P\d*)$', views.rate_movie, name="rate_movie"), + url(r'^movie/(?P\d+)$', views.show_movie, name="show_movie"), + url(r'^login/$', views.login, {'template_name': 'movies/login.html'}, name="login"), + url(r'^logout/$', views.logout, {'next_page': 'login'}, name='logout'), + url(r'^delete/(?P\d+)$', views.delete_rating, name='delete_rating'), + url(r'^register/$', views.user_register, name="user_register"), + url(r'genre/(?P\d+)$', views.show_genre, name="show_genre"), + url(r'genres/', views.show_genres, name="show_genres"), + url(r'freq/', views.freq_rated, name="freq_rated"), + + ) diff --git a/django-movies/movieratings/movies/views.py b/django-movies/movieratings/movies/views.py new file mode 100644 index 0000000..95dae2c --- /dev/null +++ b/django-movies/movieratings/movies/views.py @@ -0,0 +1,210 @@ + +from django.db.models import Count, Avg +from django.shortcuts import render, redirect, get_object_or_404 +from .models import Movie, Rater, Rating, Genre +from django.contrib.auth import authenticate, login, logout +from movies.forms import UserForm, ProfileForm, NewRatingForm +from django.contrib import messages +from django.utils import timezone +from django.contrib.auth.decorators import login_required + +# Create your views here. + +def index(request): + top_movies = Movie.movies.annotate(rating_count=Count('rating'), + avg_rating=Avg('rating__rating'),).filter(rating_count__gte=10).order_by('-avg_rating')[:20] + if request.user.is_authenticated(): + current_user = request.user.rater + seen = [Rating.ratings.filter(movieid=mov.id, userid=current_user).exists() for mov in top_movies] + zipped = zip(top_movies, seen) + return render(request, 'movies/index.html', {"top_movies": zipped}) + else: + return render(request, 'movies/index.html', {"top_movies": top_movies}) + + +def show_user(request, user_id): + user = Rater.raters.get(pk=user_id) + usrname = user.user.get_username() + ratings = Rating.ratings.filter(userid=user_id) + movs = [] + for rating in ratings: + movs.append(rating.movieid) + rates = [] + for rate in ratings: + rates.append(rate.rating) + if len(rates) > 0: + average = sum(rates) / len(rates) + else: + average = 0 + zipped = zip(rates, movs, ratings) + return render(request, + "movies/show_user.html", + {"user": user, + "average": average, + "gender": user.gender, + "age": user.age, + "zipcode": user.zipcode, + "ratings": zipped, + "username": usrname}) + +def show_rating(request, rating_id): + show_rate_movie = True + rating = get_object_or_404(Rating, pk=rating_id) + movie = rating.movieid + time = rating.date + genres = movie.get_genres + review = rating.review + user = rating.userid.user.get_username() + if request.user.is_authenticated(): + if Rating.ratings.filter(movieid=movie.id, userid=request.user.rater.id).exists(): + show_rate_movie = False + user_rating = Rating.ratings.filter(movieid=movie.id, userid=request.user.rater.id)[0] + usrname = request.user.get_username() + else: + show_rate_movie = True + usrname = None + user_rating = None + + return render(request, + "movies/show_rating.html", + {"user": user, + "username": usrname, + "time": time, + "movie": movie, + "genres": genres, + "rating": rating, + "rate": show_rate_movie, + "user_rating": user_rating, + "review": review}) + +def show_movie(request, movie_id): + show_rate_movie = True + movie = Movie.movies.get(pk=movie_id) + ratings = Rating.ratings.filter(movieid=movie_id) + genres = movie.get_genres + users = [] + rates = [] + user_rating = 0 + for rating in ratings: + users.append(rating.userid) + rates.append(rating.rating) + + average = sum(rates) / len(rates) + zipped = zip(rates, users, ratings) + + if request.user.is_authenticated(): + current_user = request.user.rater + if current_user in users: + show_rate_movie = False + for rating in ratings: + if rating.userid == current_user: + user_rating = rating.rating + else: + show_rate_movie = True + + return render(request, + "movies/show_movie.html", + {"movie": movie, + "average": average, + "ratings": zipped, + "rate": show_rate_movie, + "user_rating": user_rating, + "genres": genres,}) + +@login_required(login_url='/login/') +def rate_movie(request, movie_id): + current_user_id = request.user.rater + if Rating.ratings.filter(movieid=movie_id, userid=current_user_id).exists(): + old_rating = Rating.ratings.filter(movieid=movie_id).get(userid=current_user_id) + if request.method == "GET": + rate_form = NewRatingForm(initial={'movieid': Movie.movies.get(pk=movie_id), 'userid': current_user_id}, instance=old_rating) + return render(request, "movies/rate_movie.html", {'rate_form': rate_form, 'movie_var': movie_id,}) + elif request.method == "POST": + rate_form = NewRatingForm(request.POST, initial={'movieid': Movie.movies.get(pk=movie_id), 'userid': current_user_id}, instance=old_rating) + if rate_form.is_valid(): + rate_form.save() + old_rating.save() + messages.add_message( + request, + messages.SUCCESS, + "Rating Successfully Changed.") + return redirect('/movie/{}'.format(movie_id)) + else: + if request.method == "GET": + rate_form = NewRatingForm(initial={'movieid': Movie.movies.get(pk=movie_id), 'userid': current_user_id}) + return render(request, "movies/rate_movie.html", {'rate_form': rate_form, 'movie_var': movie_id,}) + elif request.method == "POST": + rate_form = NewRatingForm(request.POST, initial={'movieid': Movie.movies.get(pk=movie_id), 'userid': current_user_id}) + if rate_form.is_valid(): + new_rate = rate_form.save(commit=False) + new_rate.userid = request.user.rater + new_rate.date = timezone.now() + new_rate.save() + messages.add_message( + request, + messages.SUCCESS, + "Movie Successfully Rated.") + return redirect('/movie/{}'.format(movie_id)) + + +def user_register(request): + if request.method == "GET": + user_form = UserForm() + profile_form = ProfileForm() + elif request.method == "POST": + user_form = UserForm(request.POST) + profile_form = ProfileForm(request.POST) + if user_form.is_valid() and profile_form.is_valid(): + user = user_form.save() + profile = profile_form.save(commit=False) + profile.user = user + profile.save() + + password = user.password + user.set_password(password) + user.save() + + user = authenticate(username=user.username, + password=password) + login(request, user) + messages.add_message( + request, + messages.SUCCESS, + "Account Successfully Created.") + return redirect('index') + return render(request, "movies/register.html", {'user_form': user_form, 'profile_form': profile_form}) + +@login_required +def delete_rating(request, rate_id): + rating = Rating.ratings.get(pk=rate_id) + rating.delete() + messages.add_message(request, messages.SUCCESS, + "You have deleted this rating.") + return redirect("show_user", request.user.rater.id) + +def show_genres(request): + genres = Genre.objects.all() + return render(request, 'movies/show_genres.html', {"genres": genres}) + +def show_genre(request, genre_id): + the_genre = Genre.objects.get(pk=genre_id) + top_movies = Movie.movies.annotate(rating_count=Count('rating'), + avg_rating=Avg('rating__rating'),).filter(rating_count__gte=7).order_by('-avg_rating').filter( + genre=the_genre)[0:20] + if request.user.is_authenticated(): + current_user = request.user.rater + seen = [Rating.ratings.filter(movieid=mov.id, userid=current_user).exists() for mov in top_movies] + zipped = zip(top_movies, seen) + return render(request, 'movies/show_genre.html', {"top_movies": zipped, "genre": the_genre.name}) + else: + return render(request, 'movies/show_genre.html', {"top_movies": top_movies, "genre": the_genre.name}) + +def freq_rated(request): + top_movies = Movie.movies.annotate(rating_count=Count('rating'),).order_by('-rating_count')[:20] + if request.user.is_authenticated(): + current_user = request.user.rater + seen = [Rating.ratings.filter(movieid=mov.id, userid=current_user).exists() for mov in top_movies] + zipped = zip(top_movies, seen) + return render(request, 'movies/freq_rated.html', {"top_movies": zipped}) + else: + return render(request, 'movies/freq_rated.html', {"top_movies": top_movies}) diff --git a/requirements.txt b/django-movies/requirements.txt similarity index 52% rename from requirements.txt rename to django-movies/requirements.txt index 4d92c4b..fd91aa2 100644 --- a/requirements.txt +++ b/django-movies/requirements.txt @@ -1,4 +1,8 @@ Django==1.8.2 +django-bootstrap3==5.4.0 +fake-factory==0.5.1 +gnureadline==6.3.3 +ipython==3.1.0 numpy==1.9.2 pandas==0.16.1 python-dateutil==2.4.2