Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e98d92f
added site
pasaunders Jan 17, 2017
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
4f39b8e
update gitignore for future
pasaunders Jan 27, 2017
c9fbb30
docstring update.
pasaunders Jan 29, 2017
5c78cc0
added additional tests
pasaunders Jan 29, 2017
86a3861
photo and album factories
pasaunders Jan 29, 2017
4c67d46
setUp methods updated
pasaunders Jan 29, 2017
fa77083
add test image and made more tests for image model
amosboldor Jan 29, 2017
8dbb229
add code so that photos can displayed
amosboldor Jan 29, 2017
a901ceb
made migrations from updated model
amosboldor Jan 29, 2017
61bdd5a
finished str test
amosboldor Jan 29, 2017
67bf70a
made some tests for album model
amosboldor Jan 29, 2017
bd1a7c1
update readme
amosboldor Jan 30, 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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ bin/
lib64
pyvenv.cfg
share/
pip-selfcheck.json
MEDIA/

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

# Rope project settings
.ropeproject

# Ignore the files in the Media directory, but not the directory itself
imagersite/MEDIA/*
!imagersite/MEDIA/.gitkeep
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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

# command to run tests
script: python imagersite/manage.py test
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
# django-imager
django introduction assignment
[![Build Status](https://travis-ci.org/pasaunders/django-imager.svg?branch=front-end-1)](https://travis-ci.org/pasaunders/django-imager)
# Django Imager
### Getting Started

Clone this repository into whatever directory you want to work from.

```bash
$ git clone 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.

```bash
$ cd django-imager
$ python3 -m venv .
$ source bin/activate
```

Once your environment has been activated, make sure to install Django and all of this project's required packages.

```bash
(django-imager) $ pip install -r requirements.pip
```

Navigate to the project root, `imagersite`, and apply the migrations for the app.

```bash
(django-imager) $ cd imagersite
(django-imager) $ ./manage.py migrate
```

Finally, run the server in order to server the app on `localhost`

```bash
(django-imager) $ ./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`.

Resources we used:
http://stackoverflow.com/questions/10180764/django-auth-login-problems
Empty file added imagersite/MEDIA/.gitkeep
Empty file.
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),
),
]
56 changes: 56 additions & 0 deletions imagersite/imager_images/migrations/0002_auto_20170129_1248.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-29 20:48
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_modified',
field=models.DateTimeField(auto_now=True, null=True),
),
migrations.AlterField(
model_name='photo',
name='date_published',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AlterField(
model_name='photo',
name='date_uploaded',
field=models.DateTimeField(auto_now_add=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),
),
]
Empty file.
68 changes: 68 additions & 0 deletions imagersite/imager_images/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible
from django.db import models
from django.contrib.auth.models import User

PUBLISHED_OPTIONS = (
("private", "private"),
("shared", "shared"),
("public", "public"),
)


def image_path(instance, file_name):
"""Upload file to media root in user folder."""
return 'user_{0}/{1}'.format(instance.user.id, file_name)


@python_2_unicode_compatible
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

class Photo(models.Model):
"""Create Photo Model."""

user = models.ForeignKey(
User,
related_name='photos',
on_delete=models.CASCADE,
)
image = models.ImageField(upload_to=image_path, blank=True, null=True)
title = models.CharField(max_length=60)
description = models.TextField(max_length=120, blank=True, null=True)
date_uploaded = models.DateTimeField(auto_now_add=True, blank=True, null=True)
date_modified = models.DateTimeField(auto_now=True, blank=True, null=True)
date_published = models.DateTimeField(null=True, blank=True)
published = models.CharField(max_length=10, choices=PUBLISHED_OPTIONS, default='public')

def __str__(self):
"""Return string description of album."""
return "{}: Photo belonging to {}".format(self.title, self.user)


@python_2_unicode_compatible
class Album(models.Model):
"""Create Album Model."""

user = models.ForeignKey(
User,
related_name="albums",
on_delete=models.CASCADE,
)
cover = models.ForeignKey(
"Photo",
null=True,
related_name="albums_covered"
)
title = models.CharField(max_length=60)
description = models.TextField(max_length=200)
photos = models.ManyToManyField(
"Photo",
related_name="albums",
symmetrical=False
)
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
date_published = models.DateTimeField(null=True, blank=True)
published = models.CharField(max_length=10, choices=PUBLISHED_OPTIONS, default="public")

def __str__(self):
"""Return String Representation of Album."""
return "{}: Album belonging to {}".format(self.title, self.user)
Binary file added imagersite/imager_images/test_img.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading