Skip to content

Commit

Permalink
animal photos can now be added
Browse files Browse the repository at this point in the history
  • Loading branch information
sayard committed Jun 12, 2017
1 parent 9ea57fb commit 0a356fa
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions animal_shelter/animal_list/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Animal(models.Model):
description.null = False
age = models.PositiveSmallIntegerField()
is_visible = models.BooleanField(default=True)
thumbnail = models.FileField(upload_to='documents/%Y/%m/%d', default=None, blank=True, null=True)

def clean(self):
validate_available_places(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{% endblock %}
{% block content %}
{% if animal.is_visible %}
<img class="img-thumbnail" src="{{ animal.thumbnail.url }}" alt="{{ animal.name }}">
<h2>{{ animal.name }}</a></h2><br />
<h3>Species: {{ animal.specie }} | Color: {{ animal.color }} | Age: {{ animal.age }}</h3>
<p>{{ animal.description }}</p>
Expand Down
9 changes: 7 additions & 2 deletions animal_shelter/animal_list/templates/animal_list/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
{% block content %}
{% for animal in object_list %}
{% if animal.is_visible%}
<h3><a href="/animals/{{ animal.id }}">{{ animal.name }} </a></h3>
<h4>Species: {{ animal.species }} | Color: {{ animal.color }}</h4>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
<a href="/animals/{{ animal.id }}"><img class="img-thumbnail" src="{{ animal.thumbnail.url }}" alt="{{ animal.name }}"></a>
</div>
<h3><a href="/animals/{{ animal.id }}">{{ animal.name }} </a></h3>
<h4>Species: {{ animal.species }} | Color: {{ animal.color }}</h4>
</div>
{% endif %}
{% endfor %}
{% endblock %}
9 changes: 8 additions & 1 deletion animal_shelter/animal_shelter/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,15 @@

STATIC_URL = '/static/'

# Settings for email sending

EMAIL_USE_TLS = True
EMAIL_HOST = email_host
EMAIL_HOST_USER = email_user
EMAIL_HOST_PASSWORD = email_pw
EMAIL_PORT = 587
EMAIL_PORT = 587

# Media storage settings

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
4 changes: 3 additions & 1 deletion animal_shelter/animal_shelter/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls import url, include
from django.contrib import admin
from django.conf.urls.static import static

admin.autodiscover()

Expand All @@ -25,4 +27,4 @@
url(r'^login/', include('home_page.urls')),
url(r'^logout/', include('home_page.urls')),
url(r'^register/', include('home_page.urls')),
]
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Binary file modified animal_shelter/db.sqlite3
Binary file not shown.

0 comments on commit 0a356fa

Please sign in to comment.