Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
1bb7e55
user profile fields built
pasaunders Jan 17, 2017
bc7867f
pre-manager statusquo
pasaunders Jan 17, 2017
50cd84c
add make profile when user is made and tests
amosboldor Jan 17, 2017
3aa40d1
add is_active and ActiveProfileManager
amosboldor Jan 17, 2017
ccb4011
added __str__ method and default app config
pasaunders Jan 17, 2017
c01f3bc
remove and fix some tests
amosboldor Jan 17, 2017
44bdabf
add requirements.pip
amosboldor Jan 17, 2017
08a4a1b
add readme
amosboldor Jan 17, 2017
0cfedb8
change is_active
amosboldor Jan 17, 2017
ee2b05d
fixed some stuff
amosboldor Jan 17, 2017
27fd374
did makemigrations
amosboldor Jan 17, 2017
53d177a
built .travis.yml and requirements.pip
pasaunders Jan 17, 2017
e2b6883
Merge branch 'models-1' of https://github.com/pasaunders/django-image…
pasaunders Jan 17, 2017
061bb4c
added readme widget
pasaunders Jan 17, 2017
071b439
travis debugging
pasaunders Jan 18, 2017
d95f9ac
travis debugging
pasaunders Jan 18, 2017
2539092
travis debugging
pasaunders Jan 18, 2017
c1b08cd
travis debugging
pasaunders Jan 18, 2017
580c94c
travis debugging
pasaunders Jan 18, 2017
e4b3546
travis debugging
pasaunders Jan 18, 2017
f9a8523
travis debugging
pasaunders Jan 18, 2017
7f5d956
travis debugging
pasaunders Jan 18, 2017
00c1b3f
add admin, some teplates and other stuff
amosboldor Jan 18, 2017
1949491
fix home template
amosboldor Jan 18, 2017
d3d1e57
change url
amosboldor Jan 18, 2017
94b6e32
some bootstrap code, one more test, requirements.pip updated
pasaunders Jan 18, 2017
e4121cb
first pass HMAC templates
pasaunders Jan 19, 2017
f05f366
first pass HMAC templates
pasaunders Jan 19, 2017
156f329
login logout and register seem to work
pasaunders Jan 19, 2017
4496d49
readme change
pasaunders Jan 19, 2017
692f00c
begin second app models
pasaunders Jan 19, 2017
c4fd524
add MEDIA folder and the gitkeep for it and gitignore lines
amosboldor Jan 19, 2017
60c823b
add fix for only add profile if created True
amosboldor Jan 19, 2017
34e6338
add MEDIA_ROOT
amosboldor Jan 19, 2017
5544449
add ability for admin to create model for images
amosboldor Jan 19, 2017
533e6e9
add photo and album models and migration
amosboldor Jan 19, 2017
399d538
update requirements.pip with Pillow==4.0.0
amosboldor Jan 19, 2017
caf4ff7
new tests
pasaunders Jan 20, 2017
b70a7b6
extend tests, needs debugging
pasaunders Jan 20, 2017
f7066ee
new templates, new login page.
pasaunders Jan 21, 2017
94ae0ec
login redirect to profile page, if user not logged in /profile/ redir…
amosboldor Jan 22, 2017
a2ee661
add more to profile template
amosboldor Jan 22, 2017
9d764c2
add so that /profile/ is current logged in user and /profile/<usernam…
amosboldor Jan 22, 2017
2b026a5
remove not needed any more public key dict
amosboldor Jan 22, 2017
ed38dd5
moved profile to urls and view to their correct place
amosboldor Jan 22, 2017
b1d348e
add photo and photos routes
amosboldor Jan 23, 2017
9024b29
add some bootstrap
amosboldor Jan 23, 2017
1aefdf1
album routes and views, tested manually. tests sketched out but none …
pasaunders Jan 24, 2017
1e76e7a
made library view and url
amosboldor Jan 24, 2017
4c93029
fix albums template
amosboldor Jan 24, 2017
f9f3a6f
update requirements.pip
amosboldor Jan 24, 2017
7d872be
all existing tests pass
pasaunders Jan 25, 2017
b66727b
working profile tests, first steps toward images tests.
pasaunders Jan 25, 2017
c7e4cd3
add photos stuff to library template
amosboldor Jan 25, 2017
6965f54
add title and description to photos template
amosboldor Jan 25, 2017
124c84e
add div container to base and stuff to login template
amosboldor Jan 25, 2017
749035a
add |title for templane user.first_name
amosboldor Jan 25, 2017
c3cdc95
turned home into class based view
amosboldor Jan 26, 2017
ab3cbcf
turn profile views into class based views
amosboldor Jan 26, 2017
0d42a98
made photo and photos views class based
amosboldor Jan 26, 2017
734ad4e
turn album and albums into classbased view
amosboldor Jan 26, 2017
1453094
made library view class based
amosboldor Jan 26, 2017
af46fd6
debuged library, added photo templates and album routes
pasaunders Jan 27, 2017
70a6ced
got add album to work
amosboldor Jan 27, 2017
4a5297c
made add photo view work
amosboldor Jan 27, 2017
2cefbcc
replace redirect url function with reverse lazy
amosboldor Jan 27, 2017
a5f1a88
add edit and edit photos
amosboldor Jan 27, 2017
a0a2f47
updating latest version with tests. really odd testing error.
pasaunders Jan 31, 2017
89fcd75
template update
pasaunders Jan 31, 2017
600bc80
debugged tests except for the dictionary update sequence element prob…
pasaunders Jan 31, 2017
0e1c669
added email backend in settings
pasaunders Jan 31, 2017
cd6027f
100% of tests working
pasaunders Jan 31, 2017
cb43ada
add
amosboldor Jan 31, 2017
d3bf1db
Merge pull request #7 from amosboldor/front-end-4
amosboldor Jan 31, 2017
f7ab1a6
Revert "add"
amosboldor Jan 31, 2017
c3cac1b
Merge pull request #9 from pasaunders/revert-7-front-end-4
amosboldor Jan 31, 2017
0e25053
first pass security, manually tested
pasaunders Feb 1, 2017
02d4dd7
Merge branch 'front-end-4' of https://github.com/pasaunders/django-im…
pasaunders Feb 1, 2017
d852374
format and fix library template
amosboldor Feb 1, 2017
d959769
installed taggit and added it to requirements.pip and setting.py
amosboldor Feb 1, 2017
8a72fc4
add tag manager to photo model add view, template and url to render a…
amosboldor Feb 1, 2017
8437102
add tags to library template
amosboldor Feb 1, 2017
e7cb4c1
add tags to photo.html template
amosboldor Feb 1, 2017
20b2c0a
add tags to every photo in album
amosboldor Feb 1, 2017
845fb58
namespacing issue in reverse_lazy resolved
pasaunders Feb 2, 2017
450fa74
add user to group on register
amosboldor Feb 2, 2017
a4a896a
navigation buttons
pasaunders Feb 3, 2017
99636ae
album update buttons
pasaunders Feb 3, 2017
5e80b79
installed djangorestframework, added to requirements.pip made new app…
amosboldor Feb 7, 2017
f4bdb45
add new app to INSTALLED_APPS in settings
amosboldor Feb 7, 2017
f43adad
add serializer, view and url for showing all the photos for a given user
amosboldor Feb 7, 2017
89544e6
fixed addalbum and editalbum redirect
pasaunders Feb 10, 2017
0c19596
fixed errored tests, test database now includes security group with u…
pasaunders Feb 10, 2017
cdef10e
add migration file
amosboldor Feb 10, 2017
a317193
some pragma no covers on indirectly tested code and tested user group…
amosboldor Feb 10, 2017
2bbc026
add two tests for profile views
amosboldor Feb 10, 2017
1f622a8
add permissions
amosboldor Feb 12, 2017
6ef1207
add pagination for photos view
amosboldor Feb 12, 2017
9dac877
added pagination for album view
amosboldor Feb 12, 2017
f40b906
add pagination for albums view
amosboldor Feb 12, 2017
777c734
add pagination for library view and added django-query-parameters to …
amosboldor Feb 12, 2017
198b804
add github Authentication
amosboldor Feb 13, 2017
6589e49
update requirements.pip
amosboldor Feb 13, 2017
3f58ef3
add way for user to edit profile
amosboldor Feb 21, 2017
f5956de
add edit profile button
amosboldor Feb 21, 2017
2fb6656
small fix for test
amosboldor Feb 21, 2017
ad9efff
add way to create group user on migration
amosboldor Feb 21, 2017
6a0f740
add fix to add all permissions
amosboldor Feb 22, 2017
19768ad
add better way to get photos
amosboldor Feb 22, 2017
665f5e2
add tests for edit profile
amosboldor Feb 22, 2017
a1d666d
added pagination tests
pasaunders Feb 22, 2017
68ce323
finish tests for library pagination and removed useless line of code
amosboldor Feb 22, 2017
1253ecf
deleted corpse code
pasaunders Feb 22, 2017
f002050
removed commented code and removed not used auth backends
amosboldor Feb 22, 2017
624d3d8
Merge branch 'imager_api' of https://github.com/pasaunders/django-ima…
amosboldor Feb 22, 2017
c576c0c
added database variables
pasaunders Feb 22, 2017
ded8747
updated readme
pasaunders Feb 23, 2017
f45744e
stopped travis from sending emails
pasaunders Feb 23, 2017
f1696ed
added url to readme
pasaunders Feb 23, 2017
3d62152
replace sorl-thumnail version and replace with git version
amosboldor Feb 23, 2017
f356f30
Merge branch 'imager_api' of https://github.com/pasaunders/django-ima…
amosboldor Feb 23, 2017
b14002b
added enviornment variables to .travis.yml
pasaunders Feb 23, 2017
20b4d8b
tweak travis file
pasaunders Feb 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bin/
lib64
pyvenv.cfg
share/
pip-selfcheck.json

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -91,3 +92,7 @@ ENV/

# Rope project settings
.ropeproject

# Ignore the files in the Media directory, but not the directory itself
imagersite/MEDIA/*
!imagersite/MEDIA/.gitkeep
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: python
python:
- "2.7"
- "3.5"

# command to install dependencies
install:
# - pip install .
- pip install -r requirements.pip

services:
- postgresql

before_script:
- psql -c 'create database travis_ci_test;' -U postgres

env:
global:
secure: "c3J0p4fxJkSRfcwkYRmsRcjkgcwnZsIk9ODOwp0061iOHMSMdgzwbxBKWloSboBHuqpH+3qR+BsmW0CiuZo2sFnifT8NTMnllhNyVOSVTVflCMHZ/rkk5VYkEsBr+ao9r1k47OZKsq6297m116ou2iOGIJVokCpRHh0cOBY28FNSt6+x9lXksfdQKS8JT8DchO7ZCbYdv3FEPGhnnyQ8bpWV9VCdBcCoXOLQfYdXXyptUwbbW9sxCyHbTKgaPl85uBchFAG6H0l9kM2jOrFfXPgCTik5pJiznS2pLbTgq+p3WhqAJcU1kBeJcZJ+TGod3kvM3mHGRklMs8evKl7edcfVHCtGMGt9vuP6uOPM+JlY2m3ANkfM2wpTz3HgO/pxg1vG0HMqywhm6Q7rxhoBZAFqGdB/oePrDesBR7JRsVis1kE5nT9Lp/9XFiLhJ0K8p1hHZW2MW3HQs10JQwqDLNCkeA9rBnOaRy2chQ2uXkOJeT6E22cD4ktYHse6ay6XWQX9VA8oiYNc4eadCT7dbdaev7J2iesNCP9FOx7We4zVtDa5gzP1p++zhiP9yFz++3Dl47HTAZrxAxtyFI4zH0l/UuCws3Z66SxjFTEs5PcwC6uIktSeGjXvabMSHZmi1KDh9zg9bXjCzf/KZXZ2OprkFgUqWjoPtP7VZ50YQ6g="

# command to run tests
script: python imagersite/manage.py test

notifications:
email: false
113 changes: 111 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,111 @@
# django-imager
django introduction assignment
[![Build Status](https://travis-ci.org/pasaunders/django-imager.svg?branch=deployment)](https://travis-ci.org/pasaunders/django-imager)
# Django-Imager
An image display app built in django as a learning project

Creators:

Amos Bolder, Patrick Saunders

URL: http://ec2-54-202-239-113.us-west-2.compute.amazonaws.com/


##Getting Started

Clone this repository into whatever directory you want to work from.
```
https://github.com/pasaunders/django-imager.git
```
Assuming that you have access to Python 3 at the system level, start up a new virtual environment.
```
$ cd django-imager
$ python3 -m venv ENV
$ source ENV/bin/activate
```
Once your environment has been activated, make sure to install Django and all of this project's required packages.
```
$ pip install -r requirements.pip
```
Navigate to the project root, imagersite, and apply the migrations for the app.
```
$ cd imagersite

$ ./manage.py migrate
```
Finally, run the server in order to server the app on localhost
```
$ ./manage.py runserver
```
Django will typically serve on port 8000, unless you specify otherwise. You can access the locally-served site at the address http://localhost:8000.


##Current Models (outside of Django built-ins):

This application allow users to store and organize photos.

**The `ImagerProfile` model contains:**

- Address
- Bio
- Personal website
- Whether the user is for hire
- Distance the user is willing to travel for work
- Phone contact
- User's preferred style of photography
- The model manager has been edited to provide a list of active users

**The `Photo` model contains:**

- The Image
- Image title
- A description of the image
- Records of the dates when the image was uploaded, last modified, and published.
- Whether the image is public, private or shared
Photos are associated with users in a many-to-one relationship

**The `Album` model contains:**

- An album cover image
- Album title
- A description of the album
- Date the album was created, modified and published
- Whether the album is public, private or shared
Albums are associated with users in a many-to-one relationship
Albums are associated with photos in a many-to-many relationship

##Current URL Routes

- `/admin` Superuser admin page
- `/` Home page
- `/login` Login page
- `/logout` Logout route, no view
- `/accounts/register` Register a user form
- `/accounts/activate/complete/` Activation complete view
- `/accounts/register/complete/` Registration complete, email sent
- `/profile/` Authenticated user's profile view
- `/profile/edit/` Profile edit view
- `/profile/<username>/` Profile view for named user
- `/images/photos/add/` Add a photo
- `/images/<photo_id>/` View a single photo
- `/images/<photo_id>/edit` Edit a photo
- `/images/photos/` View all of an authenticated user's authorized photos
- `/images/albums/<album_id>/` View a particular album
- `/images/albums/<album_id>/edit` Edit an album
- `/images/albums/add/` Add an album
- `/images/albums/` View all authorized volumes
- `/images/library/` View authenticated user's library
- `/images/tagged/<slug>/` View photos with a tag
- `/api/v1/` Api access
- `/oauth/` Social django package


##Running Tests

Running tests for the django-imager is fairly straightforward. Navigate to the same directory as the manage.py file and type:
```
$ coverage run manage.py test
```
This will show you which tests have failed, which tests have passed. If you'd like a report of the actual coverage of your tests, type
```
$ coverage report
```
This will read from the included .coverage file, with configuration set in the .coveragerc file. Currently the configuration will show which lines were missing from the test coverage.
20 changes: 20 additions & 0 deletions imagersite/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[run]
omit =
*/migrations/*,
*/tests.py
manage.py
imagersite/wsgi.py
imagersite/urls.py
imagersite/views.py
*/apps.py
*/admin.py
*/__init__.py

source =
imagersite
imager_images
imager_api
imager_profile

[report]
show_missing = True
Empty file added imagersite/MEDIA/.gitkeep
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions imagersite/imager_api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions imagersite/imager_api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ImagerApiConfig(AppConfig):
name = 'imager_api'
Empty file.
3 changes: 3 additions & 0 deletions imagersite/imager_api/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
10 changes: 10 additions & 0 deletions imagersite/imager_api/permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Permissions for api."""
from rest_framework import permissions


class Owner(permissions.BasePermission):
"""Permission to only allow owners of object to view."""

def has_object_permission(self, request, view, obj):
"""Check object permissions against the request's user."""
return obj.user == request.user
24 changes: 24 additions & 0 deletions imagersite/imager_api/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Serializers fo rest api."""
from imager_images.models import Photo
from rest_framework import serializers


class PhotosSerializer(serializers.HyperlinkedModelSerializer):
"""Serializer for Photos."""

user = serializers.ReadOnlyField(source='user.username')

class Meta:
"""Meta."""

model = Photo
fields = (
'user',
'image',
'title',
'description',
'date_uploaded',
'date_modified',
'date_published',
'published'
)
3 changes: 3 additions & 0 deletions imagersite/imager_api/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
16 changes: 16 additions & 0 deletions imagersite/imager_api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Views for restfull api."""
from imager_images.models import Photo
from rest_framework import viewsets, permissions
from imager_api.serializers import PhotosSerializer
from imager_api.permissions import Owner


class PhotoViewSet(viewsets.ReadOnlyModelViewSet):
"""Provides a list of all photos belonging to a user."""

serializer_class = PhotosSerializer
permission_classes = (permissions.IsAuthenticated, Owner)

def get_queryset(self):
"""Get photos owned by current user."""
return Photo.objects.filter(user=self.request.user)
Empty file.
5 changes: 5 additions & 0 deletions imagersite/imager_images/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin
from imager_images.models import Album, Photo

admin.site.register(Album)
admin.site.register(Photo)
5 changes: 5 additions & 0 deletions imagersite/imager_images/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ImagerImagesConfig(AppConfig):
name = 'imager_images'
61 changes: 61 additions & 0 deletions imagersite/imager_images/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-19 05:16
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import imager_images.models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Album',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=60)),
('description', models.TextField(max_length=200)),
('date_created', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
('date_published', models.DateTimeField(null=True)),
('published', models.CharField(choices=[('private', 'private'), ('shared', 'shared'), ('public', 'public')], max_length=10)),
],
),
migrations.CreateModel(
name='Photo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.ImageField(upload_to=imager_images.models.image_path)),
('title', models.CharField(max_length=60)),
('description', models.TextField(max_length=120)),
('date_uploaded', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
('date_published', models.DateTimeField(null=True)),
('published', models.CharField(choices=[('private', 'private'), ('shared', 'shared'), ('public', 'public')], max_length=10)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='photos', to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='album',
name='cover',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='albums_covered', to='imager_images.Photo'),
),
migrations.AddField(
model_name='album',
name='photos',
field=models.ManyToManyField(related_name='albums', to='imager_images.Photo'),
),
migrations.AddField(
model_name='album',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='albums', to=settings.AUTH_USER_MODEL),
),
]
46 changes: 46 additions & 0 deletions imagersite/imager_images/migrations/0002_auto_20170131_1449.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-31 22:49
from __future__ import unicode_literals

from django.db import migrations, models
import imager_images.models


class Migration(migrations.Migration):

dependencies = [
('imager_images', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='album',
name='date_published',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AlterField(
model_name='album',
name='published',
field=models.CharField(choices=[('private', 'private'), ('shared', 'shared'), ('public', 'public')], default='public', max_length=10),
),
migrations.AlterField(
model_name='photo',
name='date_published',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AlterField(
model_name='photo',
name='description',
field=models.TextField(blank=True, max_length=120, null=True),
),
migrations.AlterField(
model_name='photo',
name='image',
field=models.ImageField(blank=True, null=True, upload_to=imager_images.models.image_path),
),
migrations.AlterField(
model_name='photo',
name='published',
field=models.CharField(choices=[('private', 'private'), ('shared', 'shared'), ('public', 'public')], default='public', max_length=10),
),
]
22 changes: 22 additions & 0 deletions imagersite/imager_images/migrations/0003_photo_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-02 02:16
from __future__ import unicode_literals

from django.db import migrations
import taggit.managers


class Migration(migrations.Migration):

dependencies = [
('taggit', '0002_auto_20150616_2121'),
('imager_images', '0002_auto_20170131_1449'),
]

operations = [
migrations.AddField(
model_name='photo',
name='tags',
field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'),
),
]
Empty file.
Loading