Commit 753dd53a44dbb19e41d3ed8edadf029a86265cb9

Authored by Zambom
1 parent fd93ffd2

Removendo app 'subscriptions'...

amadeus/settings.py
... ... @@ -45,7 +45,6 @@ INSTALLED_APPS = [
45 45 'core',
46 46 'app',
47 47 'courses',
48   - 'subscriptions',
49 48 'users',
50 49 ]
51 50  
... ... @@ -74,8 +73,6 @@ TEMPLATES = [
74 73 'django.template.context_processors.request',
75 74 'django.contrib.auth.context_processors.auth',
76 75 'django.contrib.messages.context_processors.messages',
77   -
78   - 'subscriptions.context_processors.subscribed_courses',
79 76 ],
80 77 },
81 78 },
... ...
app/templates/app/index.html
... ... @@ -43,18 +43,7 @@
43 43  
44 44 {% if user|has_role:'student' %}
45 45 <h4>{% trans 'Your course(s):' %}</h4>
46   - {% if subscribed_courses|length > 0 %}
47   - <div class="list-group">
48   - {% for subscribed in subscribed_courses %}
49   - <a href="{% url 'app:course:view' subscribed.course.slug %}" class="list-group-item">
50   - {{ subscribed.course }}
51   - </a>
52   - {% endfor %}
53   - </div>
54   - <a href="{% url 'app:subscription:subscribed' %}" class="pull-right">{% trans 'See all' %}</a>
55   - {% else %}
56   - <p>{% trans 'No courses subscribed yet' %}</p>
57   - {% endif %}
  46 + <p>{% trans 'No courses subscribed yet' %}</p>
58 47 {% endif %}
59 48 {% endblock %}
60 49  
... ...
app/urls.py
... ... @@ -4,7 +4,6 @@ from . import views
4 4  
5 5 urlpatterns = [
6 6 url(r'^$', views.index, name='index'),
7   - url(r'^', include('subscriptions.urls', namespace = 'subscription')),
8 7 url(r'^', include('courses.urls', namespace = 'course')),
9 8 url(r'^cursos/participantes/$', views.participantes_curso, name='participantes_curso'),
10 9 url(r'^cursos/avaliacoes/$', views.avaliacao_curso, name='avaliacao_curso'),
... ...
subscriptions/__init__.py
subscriptions/admin.py
... ... @@ -1,9 +0,0 @@
1   -from django.contrib import admin
2   -
3   -from .models import Subscribe
4   -
5   -class SubscribeAdmin(admin.ModelAdmin):
6   - list_display = ['user', 'course']
7   - search_fields = ['user', 'course']
8   -
9   -admin.site.register(Subscribe, SubscribeAdmin)
10 0 \ No newline at end of file
subscriptions/apps.py
... ... @@ -1,5 +0,0 @@
1   -from django.apps import AppConfig
2   -
3   -
4   -class SubscriptionsConfig(AppConfig):
5   - name = 'subscriptions'
subscriptions/context_processors.py
... ... @@ -1,12 +0,0 @@
1   -from django.contrib.auth.decorators import login_required
2   -from .models import Subscribe
3   -
4   -def subscribed_courses(request):
5   - context = {}
6   -
7   - if request.user.is_anonymous:
8   - context['subscribed_courses'] = None
9   - else:
10   - context['subscribed_courses'] = Subscribe.objects.filter(user = request.user)[:3] or None
11   -
12   - return context
13 0 \ No newline at end of file
subscriptions/forms.py
... ... @@ -1,8 +0,0 @@
1   -from django import forms
2   -from django.utils.translation import ugettext_lazy as _
3   -from .models import Subscribe
4   -
5   -class SubscribeForm(forms.ModelForm):
6   - class Meta:
7   - model = Subscribe
8   - fields = ['user', 'course']
9 0 \ No newline at end of file
subscriptions/migrations/0001_initial.py
... ... @@ -1,34 +0,0 @@
1   -# -*- coding: utf-8 -*-
2   -# Generated by Django 1.9.7 on 2016-08-15 19:31
3   -from __future__ import unicode_literals
4   -
5   -from django.conf import settings
6   -from django.db import migrations, models
7   -import django.db.models.deletion
8   -
9   -
10   -class Migration(migrations.Migration):
11   -
12   - initial = True
13   -
14   - dependencies = [
15   - ('courses', '0005_auto_20160815_0922'),
16   - migrations.swappable_dependency(settings.AUTH_USER_MODEL),
17   - ]
18   -
19   - operations = [
20   - migrations.CreateModel(
21   - name='Subscribe',
22   - fields=[
23   - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
24   - ('subs_date', models.DateField(auto_now_add=True, verbose_name='Subscription Date')),
25   - ('create_date', models.DateField(auto_now_add=True, verbose_name='Creation Date')),
26   - ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courses.Course', verbose_name='Course')),
27   - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
28   - ],
29   - options={
30   - 'verbose_name_plural': 'Subscriptions',
31   - 'verbose_name': 'Subscription',
32   - },
33   - ),
34   - ]
subscriptions/migrations/__init__.py
subscriptions/models.py
... ... @@ -1,14 +0,0 @@
1   -from django.db import models
2   -from django.utils.translation import ugettext_lazy as _
3   -from courses.models import Course
4   -from users.models import User
5   -
6   -class Subscribe(models.Model):
7   - user = models.ForeignKey(User, verbose_name = _('User'))
8   - course = models.ForeignKey(Course, verbose_name = _('Course'))
9   - subs_date = models.DateField(_('Subscription Date'), auto_now_add = True)
10   - create_date = models.DateField(_('Creation Date'), auto_now_add = True)
11   -
12   - class Meta:
13   - verbose_name = _('Subscription')
14   - verbose_name_plural = _('Subscriptions')
subscriptions/templates/subscribed/index.html
... ... @@ -1,69 +0,0 @@
1   -{% extends 'app/base.html' %}
2   -
3   -{% load static i18n %}
4   -
5   -{% block breadcrumbs %}
6   - <ol class="breadcrumb">
7   - <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li>
8   - <li class="active">{% trans 'Subscribed Courses' %}</li>
9   - </ol>
10   -{% endblock %}
11   -
12   -{% block sidebar %}
13   - <div class="list-group">
14   - <a href="{% url 'app:course:manage' %}" class="list-group-item active">
15   - {% trans 'All Courses' %}
16   - </a>
17   - </div>
18   -
19   - <hr />
20   -{% endblock %}
21   -
22   -{% block content %}
23   - {% if subscriptions|length > 0 %}
24   - {% for courses in subscriptions %}
25   - <div class="row well well-inverse">
26   - <div class="col-md-2">
27   - <img src="{{ courses.course.image.url }}" class="img-responsive" />
28   - </div>
29   - <div class="col-md-10">
30   - <div class="row">
31   - <div class="col-md-12">
32   - <div class="pull-right">
33   - <a href="{% url 'app:course:view' courses.course.slug %}" class="btn btn-sm btn-info">
34   - <span class="glyphicon glyphicon-eye-open"></span>
35   - </a>
36   - </div>
37   - <h4>
38   - <a href="{% url 'app:course:view' courses.course.slug %}">
39   - {{ courses.course }}
40   - </a>
41   - </h4>
42   - <span class="label label-info">{{ courses.course.category }}</span>
43   - <span class="label label-warning">{{ courses.course.max_students }} {% trans 'students maximum' %}</span>
44   - <small>
45   - <em>{{ courses.course.objectivies|linebreaks }}</em>
46   - </small>
47   - </div>
48   - <div class="col-md-12">
49   - <strong>{% trans 'Subscribe Period:' %} </strong> <em>de</em> <u>{{ courses.course.init_register_date }}</u> <em>até</em> <u>{{ courses.course.end_register_date }}</u>
50   - <br />
51   - <strong>{% trans 'Period:' %} </strong> <em>de</em> <u>{{ courses.course.init_date }}</u> <em>até</em> <u>{{ courses.course.end_date }}</u>
52   - </div>
53   - </div>
54   - </div>
55   - </div>
56   - {% endfor %}
57   - <nav aria-label="Page navigation">
58   - <ul class="pagination">
59   - {% for page_number in paginator.page_range %}
60   - <li{% if page_obj.number == page_number %} class="active"{% endif %}>
61   - <a href="?page={{ page_number }}">{{ page_number }}</a>
62   - </li>
63   - {% endfor %}
64   - </ul>
65   - </nav>
66   - {% else %}
67   - {% trans 'No courses subscribed yet' %}
68   - {% endif %}
69   -{% endblock %}
70 0 \ No newline at end of file
subscriptions/templates/subscribed/participants.html
... ... @@ -1,99 +0,0 @@
1   -{% extends 'app/base.html' %}
2   -
3   -{% load static i18n permission_tags %}
4   -
5   -{% block breadcrumbs %}
6   - <ol class="breadcrumb">
7   - <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li>
8   - <li><a href="{% url 'app:course:view' subscribers.0.course.slug %}">{{ subscribers.0.course }}</a></li>
9   - <li class="active">{% trans 'Participants' %}</li>
10   - </ol>
11   -{% endblock %}
12   -
13   -{% block sidebar %}
14   - <div class="list-group">
15   - <a href="{% url 'app:course:manage' %}" class="list-group-item">
16   - {% trans 'Courses' %}
17   - </a>
18   - <a href="{% url 'app:course:view' subscribers.0.course.slug %}" class="list-group-item">
19   - {% trans 'Course Info' %}
20   - </a>
21   - <a href="{% url 'app:course:manage_mods' subscribers.0.course.slug %}" class="list-group-item">
22   - {% trans 'Manage Modules' %}
23   - </a>
24   - <a href="{% url 'app:course:create' %}" class="list-group-item">
25   - {% trans 'Create Course' %}
26   - </a>
27   - <a href="{% url 'app:course:update' subscribers.0.course.slug %}" class="list-group-item">
28   - {% trans 'Edit Course' %}
29   - </a>
30   - <a href="{% url 'app:subscription:participants' subscribers.0.course.slug %}" class="list-group-item active">
31   - {% trans 'Participants' %}
32   - </a>
33   - <a href="" class="list-group-item">
34   - {% trans 'Course avaliations' %}
35   - </a>
36   - <a href="" class="list-group-item">
37   - {% trans 'Duplicate Course' %}
38   - </a>
39   - <a href="{% url 'app:course:delete' subscribers.0.course.slug %}" class="list-group-item">
40   - {% trans 'Delete Course' %}
41   - </a>
42   - </div>
43   -{% endblock %}
44   -
45   -{% block content %}
46   - {% if messages %}
47   - {% for message in messages %}
48   - <div class="alert alert-success alert-dismissible" role="alert">
49   - <button type="button" class="close" data-dismiss="alert" aria-label="Close">
50   - <span aria-hidden="true">&times;</span>
51   - </button>
52   - <p>{{ message }}</p>
53   - </div>
54   - {% endfor %}
55   - {% endif %}
56   -
57   - <ul class="list-group">
58   - {% if subscribers|length > 0 %}
59   - {% for subscriber in subscribers %}
60   - <li class="list-group-item">
61   - <div class="media">
62   - <div class="col-sm-3">
63   - <img class="media-object img-responsive" src="{{ subscriber.user.image.url }}" alt="Image">
64   - </div>
65   - <div class="col-sm-6">
66   - <div class="media-body">
67   - <h4 class="media-heading">{{ subscriber.user }}</h4>
68   - <p><small>{{ subscriber.user.email }}</small></p>
69   - </div>
70   - </div>
71   - <div class="col-sm-3" style="padding-top: 10px">
72   - {% if user.type_profile %}
73   - <span class="label label-info">{{ subscriber.user.get_type_profile_display }}</span>
74   - {% else %}
75   - <span class="label label-info">{% trans 'Administrator' %}</span>
76   - {% endif %}
77   - <br />
78   - <a href="{% url 'app:users:view' subscriber.user.username %}" class="btn btn-sm btn-info" style="margin-top: 10px">
79   - <span class="glyphicon glyphicon-eye-open"></span>
80   - </a>
81   - {% if user|has_role:'system_admin' %}
82   - <a href="{% url 'app:users:update' subscriber.user.username %}" class="btn btn-sm btn-primary" style="margin-top: 10px">
83   - <span class="glyphicon glyphicon-edit"></span>
84   - </a>
85   - <a href="" class="btn btn-sm btn-danger" style="margin-top: 10px">
86   - <span class="glyphicon glyphicon-trash"></span>
87   - </a>
88   - {% endif %}
89   - </div>
90   - </div>
91   - </li>
92   - {% endfor %}
93   - {% else %}
94   - <li class="list-group-item">
95   - <p>{% trans 'No users found' %}</p>
96   - </li>
97   - {% endif %}
98   - </ul>
99   -{% endblock %}
100 0 \ No newline at end of file
subscriptions/tests.py
... ... @@ -1,3 +0,0 @@
1   -from django.test import TestCase
2   -
3   -# Create your tests here.
subscriptions/urls.py
... ... @@ -1,9 +0,0 @@
1   -from django.conf.urls import url
2   -
3   -from . import views
4   -
5   -urlpatterns = [
6   - url(r'^subscribe/$', views.subscribe, name='subscribe'),
7   - url(r'^cursos/subscribed/$', views.Index.as_view(), name='subscribed'),
8   - url(r'^cursos/(?P<slug>[\w_-]+)/participants/$', views.Participants.as_view(), name='participants'),
9   -]
10 0 \ No newline at end of file
subscriptions/views.py
... ... @@ -1,51 +0,0 @@
1   -from django.shortcuts import render, get_object_or_404, redirect
2   -from django.views import generic
3   -from django.contrib import messages
4   -from django.core.paginator import Paginator, EmptyPage
5   -from django.contrib.auth.decorators import login_required
6   -from django.contrib.auth.mixins import LoginRequiredMixin
7   -from django.utils.translation import ugettext_lazy as _
8   -from rolepermissions.mixins import HasRoleMixin
9   -from .forms import SubscribeForm
10   -from .models import Subscribe
11   -from courses.models import Course
12   -
13   -@login_required
14   -def subscribe(request):
15   - if request.method == 'POST':
16   - print(request.POST)
17   - form = SubscribeForm(request.POST)
18   -
19   - print(form)
20   -
21   - if form.is_valid():
22   - form.save()
23   -
24   - messages.success(request, _('Course subscribed successfully!'))
25   -
26   - return redirect('app:course:manage')
27   -
28   -class Index(HasRoleMixin, LoginRequiredMixin, generic.ListView):
29   -
30   - allowed_roles = ['student']
31   - login_url = '/'
32   - redirect_field_name = 'next'
33   - template_name = 'subscribed/index.html'
34   - context_object_name = 'subscriptions'
35   - paginate_by = 10
36   -
37   - def get_queryset(self):
38   - return Subscribe.objects.filter(user = self.request.user)
39   -
40   -class Participants(HasRoleMixin, LoginRequiredMixin, generic.ListView):
41   -
42   - allowed_roles = ['professor', 'system_admin']
43   - login_url = '/'
44   - redirect_field_name = 'next'
45   - template_name = 'subscribed/participants.html'
46   - context_object_name = 'subscribers'
47   - paginate_by = 10
48   -
49   - def get_queryset(self):
50   - course = get_object_or_404(Course, slug = self.kwargs.get('slug'))
51   - return Subscribe.objects.filter(course = course)
52 0 \ No newline at end of file