Commit ade3280ded641e47faaf9465254bc0589378036e

Authored by Zambom
1 parent 57ec3dfd

Creating Files app and Model [Issue: #127]

files/__init__.py 0 → 100644
files/admin.py 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +from django.contrib import admin
  2 +
  3 +# Register your models here.
... ...
files/apps.py 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +from django.apps import AppConfig
  2 +
  3 +
  4 +class FilesConfig(AppConfig):
  5 + name = 'files'
... ...
files/migrations/__init__.py 0 → 100644
files/models.py 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +from django.db import models
  2 +from django.utils.translation import ugettext_lazy as _
  3 +
  4 +from courses.models import Activity
  5 +
  6 +"""
  7 + Function to return the path where the file should be saved
  8 +"""
  9 +def file_path(instance, filename):
  10 + return '/'.join([instance.topic.subject.course.slug, instance.topic.subject.slug, instance.topic.slug, filename])
  11 +
  12 +
  13 +"""
  14 + It's one kind of activity available for a Topic.
  15 + It's like a support material for the students.
  16 +"""
  17 +class TopicFiles(Activity):
  18 + file_url = models.FileField(verbose_name = _("File"), upload_to = file_path)
  19 +
  20 + class Meta:
  21 + verbose_name = _("File")
  22 + verbose_name_plural = _("Files")
  23 +
  24 + def __str__(self):
  25 + return self.name
0 26 \ No newline at end of file
... ...
files/tests.py 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +from django.test import TestCase
  2 +
  3 +# Create your tests here.
... ...
files/views.py 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +from django.shortcuts import render
  2 +
  3 +# Create your views here.
... ...