diff options
-rwxr-xr-x | pytask/settings.py | 6 | ||||
-rwxr-xr-x | pytask/taskapp/models.py | 2 | ||||
-rw-r--r-- | pytask/templates/task/view.html | 2 | ||||
-rw-r--r-- | pytask/templates/task/view_work.html | 2 | ||||
-rw-r--r-- | pytask/templates/templatetags/_as_full_path.html | 23 | ||||
-rw-r--r-- | pytask/templatetags/browse_helpers.py | 14 | ||||
-rwxr-xr-x | pytask/urls.py | 2 |
7 files changed, 44 insertions, 7 deletions
diff --git a/pytask/settings.py b/pytask/settings.py index 3c1a7fa..655c132 100755 --- a/pytask/settings.py +++ b/pytask/settings.py @@ -30,6 +30,8 @@ import os from pytask.local import * +ROOT = os.path.dirname(__file__) + ADMINS = ( ('Madhusudan C.S.', 'madhusudancs@fossee.in'), @@ -65,7 +67,7 @@ MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'uploads') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com", "http://example.com/media/" -MEDIA_URL = '/pytask/media/' +MEDIA_URL = '/pytask/uploads/' # Absolute path to the directory that holds static files. # Example: "/home/static-files/static-files.lawrence.com/" @@ -145,4 +147,4 @@ DEFAULT_FROM_EMAIL = 'FOSSEE Admin <admin@fossee.in>' UPLOAD_BASE_DIR = os.path.join(MEDIA_ROOT, 'pytask') -ALLOWED_INCLUDE_ROOTS = (UPLOAD_BASE_DIR,) +ALLOWED_INCLUDE_ROOTS = (UPLOAD_BASE_DIR, MEDIA_ROOT,) diff --git a/pytask/taskapp/models.py b/pytask/taskapp/models.py index 8237f74..a4fa391 100755 --- a/pytask/taskapp/models.py +++ b/pytask/taskapp/models.py @@ -157,7 +157,7 @@ class WorkReport(models.Model): attachment = models.FileField( verbose_name='Your work to upload', upload_to=lambda inst, fn: \ - os.path.join(settings.UPLOAD_BASE_DIR, str(inst.task.parent.id), + os.path.join(str(inst.task.parent.id), str(inst.task.id), fn)) revision = models.PositiveIntegerField(default=0) diff --git a/pytask/templates/task/view.html b/pytask/templates/task/view.html index 058a659..327c821 100644 --- a/pytask/templates/task/view.html +++ b/pytask/templates/task/view.html @@ -136,7 +136,7 @@ along with PyTask. If not, see <http://www.gnu.org/licenses/>. {% if report.attachment %} {% pygment cssclass="codehilite" %} <pre lang="python"> - {% ssi report.attachment.url|safe %} + {% as_full_path report.attachment.url %} </pre> {% endpygment %}<br/><br/><br/><br/> {% endif %} diff --git a/pytask/templates/task/view_work.html b/pytask/templates/task/view_work.html index b8029b7..d86ba60 100644 --- a/pytask/templates/task/view_work.html +++ b/pytask/templates/task/view_work.html @@ -35,7 +35,7 @@ along with PyTask. If not, see <http://www.gnu.org/licenses/>. <tr> <td>{{rep.submitted_by}}</td> <td><a href="{% url view_report rep.id %}">{{rep.data}}</a></td> - <td><a href="{{rep.attachment.url}}">{{rep.attachment.name}}</a> </td> + <td><a href="{{rep.attachment.url}}">Download</a> </td> </tr> {% endfor %} </table> diff --git a/pytask/templates/templatetags/_as_full_path.html b/pytask/templates/templatetags/_as_full_path.html new file mode 100644 index 0000000..6ae1ba2 --- /dev/null +++ b/pytask/templates/templatetags/_as_full_path.html @@ -0,0 +1,23 @@ +{% comment %} +Copyright 2011 Authors of PyTask. + +This file is part of PyTask. + +PyTask is free software: you can redistribute it and/or modify it +under the terms of the GNU Affero General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +PyTask is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with PyTask. If not, see <http://www.gnu.org/licenses/>. +{% endcomment%} + +{% load ssi from future %} + + +{% ssi fullpath %}
\ No newline at end of file diff --git a/pytask/templatetags/browse_helpers.py b/pytask/templatetags/browse_helpers.py index d678a79..1b488f9 100644 --- a/pytask/templatetags/browse_helpers.py +++ b/pytask/templatetags/browse_helpers.py @@ -27,8 +27,9 @@ __authors__ = [ '"Madhusudan.C.S" <madhusudancs@fossee.in>', ] - +import os from django import template +from django.conf import settings register = template.Library() @@ -77,3 +78,14 @@ def as_tags(tags): return { 'tags': tags, } + +@register.inclusion_tag('templatetags/_as_full_path.html') +def as_full_path(path): + """Returns a full path of the file with reference + to the settings.UPLOAD_BASE_DIR""" + + fullpath = os.getcwd()+path + + return{ + 'fullpath': fullpath + }
\ No newline at end of file diff --git a/pytask/urls.py b/pytask/urls.py index 7d5a197..8ac480c 100755 --- a/pytask/urls.py +++ b/pytask/urls.py @@ -62,7 +62,7 @@ urlpatterns = patterns('', # Serve static files in DEVELOPMENT = True mode if settings.DEVELOPMENT: urlpatterns += patterns('', - (r'^pytask/media/(?P<path>.*)$', 'django.views.static.serve', + (r'^pytask/uploads/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), (r'^pytask/static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}), |