From 52ba6c424d2137dc29436b45a0b5823e96a07e4a Mon Sep 17 00:00:00 2001 From: Matheus Lins Date: Mon, 24 Oct 2016 14:17:19 -0300 Subject: [PATCH] replicate couse #189 --- courses/models.py | 4 +++- courses/static/js/course.js | 14 ++++++++++++++ courses/templates/course/course_card.html | 4 ++-- courses/urls.py | 1 + courses/views.py | 34 ++++++++++++++++++++++++++++++++-- 5 files changed, 52 insertions(+), 5 deletions(-) diff --git a/courses/models.py b/courses/models.py index e3658e3..ac70427 100644 --- a/courses/models.py +++ b/courses/models.py @@ -65,9 +65,11 @@ class Course(models.Model): def show_subscribe(self): today = datetime.date.today() - return today >= self.init_register_date and today <= self.end_register_date + def duration(self): + return self.end_date - self.init_date + class Subject(models.Model): name = models.CharField(_('Name'), max_length = 100) diff --git a/courses/static/js/course.js b/courses/static/js/course.js index 9fdee96..9a16d64 100644 --- a/courses/static/js/course.js +++ b/courses/static/js/course.js @@ -63,4 +63,18 @@ function delete_course(url, course, message, return_url) { } }); }); +} +/* +* +* Function to load create course's form +* +*/ +function replicate_course(url, course) { + $.ajax({ + url: url, + data: {'form': course}, + success: function(data) { + $(".course_replicate_form").html(data); + } + }); } \ No newline at end of file diff --git a/courses/templates/course/course_card.html b/courses/templates/course/course_card.html index 8007078..1fb31f1 100644 --- a/courses/templates/course/course_card.html +++ b/courses/templates/course/course_card.html @@ -18,7 +18,7 @@ @@ -47,7 +47,7 @@