diff --git a/courses/models.py b/courses/models.py index 9db0eb0..16306f0 100644 --- a/courses/models.py +++ b/courses/models.py @@ -1,5 +1,6 @@ from django.utils.translation import ugettext_lazy as _ from django.db import models +import datetime from autoslug.fields import AutoSlugField from users.models import User from core.models import Resource, MimeType @@ -79,6 +80,11 @@ class Subject(models.Model): def __str__(self): return self.name + def show_subscribe(self): + today = datetime.date.today() + + return today < self.init_date + class Topic(models.Model): name = models.CharField(_('Name'), max_length = 100) diff --git a/courses/static/js/course.js b/courses/static/js/course.js index 47d2110..f0287ce 100644 --- a/courses/static/js/course.js +++ b/courses/static/js/course.js @@ -10,7 +10,7 @@ function subscribe(elem, url, confirm_message) { url: url, success: function (data) { if (data.status == "ok") { - elem.disabled(true); + elem.remove(); alertify.success(data.message); } else { alertify.error(data.message); diff --git a/courses/templates/course/view.html b/courses/templates/course/view.html index 6a35636..cb3e92d 100644 --- a/courses/templates/course/view.html +++ b/courses/templates/course/view.html @@ -7,6 +7,10 @@ {% endblock style %} +{% block javascript %} + +{% endblock %} + {% block breadcrumbs %} {{ block.super }} @@ -212,6 +216,12 @@ {% endif %} + + {% if user|has_role:'student' and not user in subject.students.all and subject.show_subscribe %} +
+ {% endif %}