Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added default pic to stories.

  • Loading branch information...
commit ea17f2b70df6f37a1fb0238971576b1f29b635be 1 parent cd950de
Derek Hoy authored
View
3  .gitignore
@@ -27,4 +27,5 @@ ecengine/engineclub
/engineclub/static/media
/engineclub/static/verticaltabs
/engineclub/static/favicon.ico
-sql_data/dump.tgz
+sql_data/dump.tgz
+engineclub/media/
View
3  engineclub/apps/cab/stories/templates/stories/stories_carousel.html
@@ -1,4 +1,5 @@
{% load url from future %}
+{% load stories_tags %}
{% if objects %}
<div class="carousel">
@@ -8,7 +9,7 @@
<p><a href="{% url 'stories_list' %}">Read more...</a></p>
</div>
{% for object in objects %}
- <img src="/static/stories/{{object.id}}.jpg" alt="{{ object.note|truncatewords:10 }}" data-caption="#htmlCaption{{forloop.counter}}" />
+ <img src="{{ object.id|pic:"500,400"}}" alt="{{ object.note|truncatewords:10 }}" data-caption="#htmlCaption{{forloop.counter}}" />
<span class="orbit-caption" id="htmlCaption{{forloop.counter}}"><a href="{% url 'stories_detail' object.id %}">{{ object.note|truncatewords:10 }}</a></span>
{% endfor %}
</div>
View
9 engineclub/apps/cab/stories/templatetags/stories_tags.py
@@ -1,5 +1,7 @@
# stories_tags.py
+import os
+
from django.conf import settings
from django.template import Library
from django.utils.safestring import mark_safe
@@ -12,3 +14,10 @@
def carousel():
objects = Curation.objects(tags=settings.STORY_TAG)
return {'objects': objects}
+
+@register.filter
+def pic(value, size):
+ path = '%s/images/stories/%s.jpg' % (settings.MEDIA_ROOT, value)
+ if os.path.exists(path):
+ return '%simages/stories/%s.jpg' % (settings.MEDIA_URL, value)
+ return 'http://placekitten.com/%s' % '/'.join(size.split(','))
View
8 engineclub/apps/engine/resources/views.py
@@ -110,7 +110,7 @@ def resource_add(request, template_name='depot/resource_edit.html'):
if request.POST.get('result', '') == 'Cancel':
return resource_edit_complete(request, None, template_info)
form = ShortResourceForm(request.POST)
- if form.is_valid():
+ if form.is_valid(request.user):
resource = Resource(**form.cleaned_data)
# resource.metadata.author = str(request.user.id)
try:
@@ -162,7 +162,7 @@ def resource_edit(request, object_id, template_name='depot/resource_edit.html'):
locationform = LocationUpdateForm(request.POST, instance=resource)
# shelflifeform = ShelflifeForm(request.POST, instance=resource)
- if resourceform.is_valid() and locationform.is_valid() and eventform.is_valid():
+ if resourceform.is_valid(request.user) and locationform.is_valid() and eventform.is_valid():
acct = get_account(request.user.id)
resource.locations = locationform.locations
@@ -325,7 +325,7 @@ def curation_add(request, object_id, template_name='depot/curation_edit.html'):
if result == 'Cancel':
return HttpResponseRedirect(reverse('resource', args=[resource.id]))
form = CurationForm(request.POST)
- if form.is_valid():
+ if form.is_valid(request.user):
curation = Curation(**form.cleaned_data)
curation.owner = user
curation.item_metadata.update(author=user)
@@ -367,7 +367,7 @@ def curation_edit(request, object_id, index, template_name='depot/curation_edit.
if result == 'Cancel':
return HttpResponseRedirect(reverse('curation', args=[resource.id, index]))
form = CurationForm(request.POST, instance=object)
- if form.is_valid():
+ if form.is_valid(request.user):
user = get_account(request.user.id)
curation = form.save(do_save=False)
curation.item_metadata.update(author=user)
View
3  engineclub/urls.py
@@ -38,6 +38,9 @@
(r'^accounts/password_change/done/$', 'password_change_done' ),
)
+# from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+# urlpatterns += staticfiles_urlpatterns()
+
if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$',
Please sign in to comment.
Something went wrong with that request. Please try again.