-
Notifications
You must be signed in to change notification settings - Fork 0
Models 2 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amosboldor
wants to merge
51
commits into
master
Choose a base branch
from
models-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Models 2 #2
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
e98d92f
added site
pasaunders 1bb7e55
user profile fields built
pasaunders bc7867f
pre-manager statusquo
pasaunders 50cd84c
add make profile when user is made and tests
amosboldor 3aa40d1
add is_active and ActiveProfileManager
amosboldor ccb4011
added __str__ method and default app config
pasaunders c01f3bc
remove and fix some tests
amosboldor 44bdabf
add requirements.pip
amosboldor 08a4a1b
add readme
amosboldor 0cfedb8
change is_active
amosboldor ee2b05d
fixed some stuff
amosboldor 27fd374
did makemigrations
amosboldor 53d177a
built .travis.yml and requirements.pip
pasaunders e2b6883
Merge branch 'models-1' of https://github.com/pasaunders/django-image…
pasaunders 061bb4c
added readme widget
pasaunders 071b439
travis debugging
pasaunders d95f9ac
travis debugging
pasaunders 2539092
travis debugging
pasaunders c1b08cd
travis debugging
pasaunders 580c94c
travis debugging
pasaunders e4b3546
travis debugging
pasaunders f9a8523
travis debugging
pasaunders 7f5d956
travis debugging
pasaunders 00c1b3f
add admin, some teplates and other stuff
amosboldor 1949491
fix home template
amosboldor d3d1e57
change url
amosboldor 94b6e32
some bootstrap code, one more test, requirements.pip updated
pasaunders e4121cb
first pass HMAC templates
pasaunders f05f366
first pass HMAC templates
pasaunders 156f329
login logout and register seem to work
pasaunders 4496d49
readme change
pasaunders 692f00c
begin second app models
pasaunders c4fd524
add MEDIA folder and the gitkeep for it and gitignore lines
amosboldor 60c823b
add fix for only add profile if created True
amosboldor 34e6338
add MEDIA_ROOT
amosboldor 5544449
add ability for admin to create model for images
amosboldor 533e6e9
add photo and album models and migration
amosboldor 399d538
update requirements.pip with Pillow==4.0.0
amosboldor caf4ff7
new tests
pasaunders b70a7b6
extend tests, needs debugging
pasaunders 4f39b8e
update gitignore for future
pasaunders c9fbb30
docstring update.
pasaunders 5c78cc0
added additional tests
pasaunders 86a3861
photo and album factories
pasaunders 4c67d46
setUp methods updated
pasaunders fa77083
add test image and made more tests for image model
amosboldor 8dbb229
add code so that photos can displayed
amosboldor a901ceb
made migrations from updated model
amosboldor 61bdd5a
finished str test
amosboldor 67bf70a
made some tests for album model
amosboldor bd1a7c1
update readme
amosboldor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,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 |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,42 @@ | ||
| # django-imager | ||
| django introduction assignment | ||
| [](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.
Empty file.
This file contains hidden or 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,5 @@ | ||
| from django.contrib import admin | ||
| from imager_images.models import Album, Photo | ||
|
|
||
| admin.site.register(Album) | ||
| admin.site.register(Photo) |
This file contains hidden or 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,5 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class ImagerImagesConfig(AppConfig): | ||
| name = 'imager_images' |
This file contains hidden or 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,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
56
imagersite/imager_images/migrations/0002_auto_20170129_1248.py
This file contains hidden or 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,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.
This file contains hidden or 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,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 | ||
| 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) | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good