Commit 4f7868a5c218bc6242b16d3d94718c6198a00777
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
16 changed files
with
539 additions
and
117 deletions
Show diff stats
README.md
... | ... | @@ -86,3 +86,24 @@ Para Classes que envolvem formulários: |
86 | 86 | [2] https://github.com/FezVrasta/bootstrap-material-design |
87 | 87 | |
88 | 88 | [Django Breadcrumbs](http://django-bootstrap-breadcrumbs.readthedocs.io/en/latest/) |
89 | + | |
90 | + | |
91 | +## Sprint WorkFlow | |
92 | +[PT-BR] | |
93 | +**Dia : Atividade** | |
94 | +* 01 Segunda: Retrospective/Planning | |
95 | +* 05 Sexta: Review | |
96 | +* 08 Segunda: Weekly Meeting | |
97 | +* 10 Quarta: Sprint Deadline | |
98 | +* 11 Quinta: Review | |
99 | +* 12 Sexta: Deploy | |
100 | + | |
101 | +[EN-US] | |
102 | + | |
103 | +**Day : Activity** | |
104 | +* 01 Monday: Retrospective/Planning | |
105 | +* 05 Friday: Review | |
106 | +* 08 Monday: Weekly Meeting | |
107 | +* 10 Wednesday: Sprint Deadline | |
108 | +* 11 Thursday: Review | |
109 | +* 12 Friday: Deploy | ... | ... |
amadeus/settings.py
... | ... | @@ -12,6 +12,11 @@ https://docs.djangoproject.com/en/1.9/ref/settings/ |
12 | 12 | |
13 | 13 | import os |
14 | 14 | |
15 | +import dj_database_url | |
16 | + | |
17 | +db_from_ev = dj_database_url.config(conn_max_age=500) | |
18 | + | |
19 | + | |
15 | 20 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
16 | 21 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
17 | 22 | |
... | ... | @@ -95,14 +100,7 @@ WSGI_APPLICATION = 'amadeus.wsgi.application' |
95 | 100 | # https://docs.djangopr/*oject.com/en/1.9/ref/settings/#databases |
96 | 101 | |
97 | 102 | DATABASES = { |
98 | - 'default': { | |
99 | - 'ENGINE': 'django.db.backends.postgresql', | |
100 | - 'NAME': 'amadeus', | |
101 | - 'USER': 'amadeus_admin', | |
102 | - 'PASSWORD': 'amadeus', | |
103 | - 'HOST': '127.0.0.1', | |
104 | - 'PORT': '5432', | |
105 | - } | |
103 | + 'default': db_from_ev | |
106 | 104 | } |
107 | 105 | |
108 | 106 | ... | ... |
core/templates/base.html
... | ... | @@ -22,11 +22,14 @@ |
22 | 22 | <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/material.min.css' %}"> |
23 | 23 | <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/ripples.min.css' %}"> |
24 | 24 | <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/datepicker.css' %}"> |
25 | + <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/alertifyjs/alertify.min.css' %}"> | |
26 | + <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/alertifyjs/themes/bootstrap.css' %}"> | |
25 | 27 | <script type="text/javascript" src="{% static 'bootstrap-3.3.7/js/bootstrap.js' %}"></script> |
26 | 28 | <script type="text/javascript" src="{% static 'js/vendor/bootstrap-acessibility.min.js' %}"></script> |
27 | 29 | <script type="text/javascript" src="{% static 'js/vendor/material.min.js' %}"></script> |
28 | 30 | <script type="text/javascript" src="{% static 'js/vendor/ripples.min.js' %}"></script> |
29 | 31 | <script type="text/javascript" src="{% static 'js/vendor/bootstrap-datepicker.js' %}"></script> |
32 | + <script type="text/javascript" src="{% static 'js/vendor/alertify.min.js' %}"></script> | |
30 | 33 | |
31 | 34 | <!-- Font awesome --> |
32 | 35 | <link rel="stylesheet" type="text/css" href="{% static 'font-awesome-4.6.3/css/font-awesome.min.css' %}"> | ... | ... |
... | ... | @@ -0,0 +1,30 @@ |
1 | +# -*- coding: utf-8 -*- | |
2 | +# Generated by Django 1.10 on 2016-10-03 16:10 | |
3 | +from __future__ import unicode_literals | |
4 | + | |
5 | +from django.db import migrations, models | |
6 | +import django.db.models.deletion | |
7 | +import s3direct.fields | |
8 | + | |
9 | + | |
10 | +class Migration(migrations.Migration): | |
11 | + | |
12 | + dependencies = [ | |
13 | + ('courses', '0002_auto_20161001_2117'), | |
14 | + ] | |
15 | + | |
16 | + operations = [ | |
17 | + migrations.CreateModel( | |
18 | + name='ActivityFile', | |
19 | + fields=[ | |
20 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
21 | + ('pdf', s3direct.fields.S3DirectField()), | |
22 | + ('name', models.CharField(max_length=100)), | |
23 | + ('diet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='files', to='courses.Activity')), | |
24 | + ], | |
25 | + options={ | |
26 | + 'verbose_name_plural': 'Activitys Files', | |
27 | + 'verbose_name': 'Activity File', | |
28 | + }, | |
29 | + ), | |
30 | + ] | ... | ... |
courses/templates/topic/list_topic_foruns.html
1 | 1 | {% for forum in foruns %} |
2 | - <a id="forum_{{ forum.id }}" href="javascript:showForum('{% url 'forum:index' %}', '{{forum.id}}')">{{ forum }}</a><br /> | |
2 | + <a id="forum_{{ forum.id }}" href="javascript:showForum('{% url 'forum:index' %}', '{{forum.id}}')">{{ forum }}<br /></a> | |
3 | 3 | {% endfor %} |
4 | 4 | \ No newline at end of file | ... | ... |
forum/static/js/forum.js
... | ... | @@ -39,7 +39,7 @@ function createForum(url, topic) { |
39 | 39 | console.log(data); |
40 | 40 | data = data.split('-'); |
41 | 41 | |
42 | - $('.foruns_list').append("<a id='forum_"+data[1]+"' href='javascript:"+showForum(data[0], data[1])+"'>"+data[2]+"</a><br />"); | |
42 | + $('.foruns_list').append("<a id='forum_"+data[1]+"' href='javascript:showForum("+data[0]+","+data[1]+")'>"+data[2]+"<br /></a>"); | |
43 | 43 | |
44 | 44 | $("#createForum").modal('hide'); |
45 | 45 | |
... | ... | @@ -57,7 +57,6 @@ function createForum(url, topic) { |
57 | 57 | $("#createForum").modal(); |
58 | 58 | } |
59 | 59 | |
60 | - | |
61 | 60 | /* |
62 | 61 | * |
63 | 62 | * Function to load forum to modal |
... | ... | @@ -93,6 +92,23 @@ function showForum(url, forum_id) { |
93 | 92 | $('#forumModal').modal(); |
94 | 93 | } |
95 | 94 | |
95 | +function delete_forum(url, forum, message) { | |
96 | + alertify.confirm(message, function(){ | |
97 | + var csrftoken = getCookie('csrftoken'); | |
98 | + | |
99 | + $.ajax({ | |
100 | + method: 'post', | |
101 | + beforeSend: function (request) { | |
102 | + request.setRequestHeader('X-CSRFToken', csrftoken); | |
103 | + }, | |
104 | + url: url, | |
105 | + success: function(data) { | |
106 | + $("#forum_"+forum).remove(); | |
107 | + $('#forumModal').modal('hide'); | |
108 | + } | |
109 | + }); | |
110 | + }); | |
111 | +} | |
96 | 112 | |
97 | 113 | /* |
98 | 114 | * | ... | ... |
forum/templates/forum/forum_list.html
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | </a> |
15 | 15 | <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> |
16 | 16 | <li><a href="javascript:edit_forum('{% url 'forum:index' %}', '{{ forum.id }}')"><i class="material-icons">create</i> {% trans 'Edit' %}</a></li> |
17 | - | |
17 | + <li><a href="javascript:delete_forum('{% url 'forum:delete' forum.id %}', '{{ forum.id }}', '{% trans "Are you sure you want to delete this forum?" %}')"><i class="material-icons">delete_sweep</i> {% trans 'Delete' %}</a></li> | |
18 | 18 | </ul> |
19 | 19 | </div> |
20 | 20 | {% endif %} | ... | ... |
... | ... | @@ -0,0 +1,130 @@ |
1 | +from django.test import TestCase | |
2 | +from rolepermissions.shortcuts import assign_role | |
3 | + | |
4 | +from users.models import User | |
5 | +from courses.models import Category, Course, Subject, Topic | |
6 | +from forum.models import Forum, Post, PostAnswer | |
7 | + | |
8 | +class PostAnswerTestCase (TestCase): | |
9 | + | |
10 | + def setUp (self): | |
11 | + self.user_professor = User.objects.create_user( | |
12 | + username = 'professor', | |
13 | + email = 'professor@amadeus.com', | |
14 | + is_staff = False, | |
15 | + is_active = True, | |
16 | + password = 'testing', | |
17 | + type_profile = 1 | |
18 | + ) | |
19 | + assign_role(self.user_professor, 'professor') | |
20 | + | |
21 | + self.user_student = User.objects.create_user( | |
22 | + username = 'student', | |
23 | + email = 'student@amadeus.com', | |
24 | + is_staff = False, | |
25 | + is_active = True, | |
26 | + password = 'testing', | |
27 | + type_profile = 2 | |
28 | + ) | |
29 | + assign_role(self.user_student, 'student') | |
30 | + | |
31 | + self.category = Category.objects.create( | |
32 | + name = 'Categoria Teste', | |
33 | + slug = 'categoria_teste' | |
34 | + ) | |
35 | + self.category.save() | |
36 | + | |
37 | + self.course = Course.objects.create( | |
38 | + name = 'Curso Teste', | |
39 | + slug = 'curso_teste', | |
40 | + max_students = 50, | |
41 | + init_register_date = '2016-08-26', | |
42 | + end_register_date = '2016-10-01', | |
43 | + init_date = '2016-10-05', | |
44 | + end_date = '2017-10-05', | |
45 | + category = self.category | |
46 | + ) | |
47 | + self.course.save() | |
48 | + | |
49 | + self.subject = Subject.objects.create( | |
50 | + name = 'Subject Test', | |
51 | + description = "description of the subject test", | |
52 | + visible = True, | |
53 | + course = self.course, | |
54 | + init_date = '2016-10-05', | |
55 | + end_date = '2017-10-05', | |
56 | + ) | |
57 | + self.subject.save() | |
58 | + self.subject.professors.add(self.user_professor) | |
59 | + | |
60 | + self.topic = Topic.objects.create( | |
61 | + name = 'Topic Test', | |
62 | + description = "description of the topic test", | |
63 | + subject = self.subject, | |
64 | + owner = self.user_professor, | |
65 | + ) | |
66 | + self.topic.save() | |
67 | + | |
68 | + self.forum = Forum.objects.create( | |
69 | + topic=self.topic, | |
70 | + name = 'forum test', | |
71 | + description = 'description of the forum test', | |
72 | + create_date = '2016-10-02', | |
73 | + modification_date = '2016-10-03', | |
74 | + limit_date = '2017-10-05', | |
75 | + ) | |
76 | + self.forum.save() | |
77 | + | |
78 | + self.post_professor = Post.objects.create( | |
79 | + user = self.user_professor, | |
80 | + message = 'posting a test on forum as professor', | |
81 | + modification_date = '2016-11-09', | |
82 | + post_date = '2016-10-03', | |
83 | + forum = self.forum, | |
84 | + ) | |
85 | + self.post_professor.save() | |
86 | + | |
87 | + self.post_student = Post.objects.create( | |
88 | + user = self.user_student, | |
89 | + message = 'posting a test on forum as student', | |
90 | + modification_date = '2016-11-09', | |
91 | + post_date = '2016-10-03', | |
92 | + forum = self.forum, | |
93 | + ) | |
94 | + self.post_student.save() | |
95 | + | |
96 | + self.answer = PostAnswer.objects.create( | |
97 | + user = self.user_student, | |
98 | + post = self.post_professor, | |
99 | + message = 'testing a post answer', | |
100 | + modification_date = '2016-10-05', | |
101 | + answer_date = '2016-10-04', | |
102 | + ) | |
103 | + | |
104 | + | |
105 | + def test_create_answer_post (self): | |
106 | + answer = PostAnswer.objects.create( | |
107 | + user = self.user_professor, | |
108 | + post = self.post_student, | |
109 | + message = 'testing a post answer2', | |
110 | + modification_date = '2016-10-05', | |
111 | + answer_date = '2016-10-04', | |
112 | + ) | |
113 | + answer.save() | |
114 | + | |
115 | + self.assertEquals (answer, PostAnswer.objects.get(user=self.user_professor, post=self.post_student)) | |
116 | + | |
117 | + def test_update_answer_post (self): | |
118 | + self.answer.message = 'updating a answer post' | |
119 | + self.answer.save() | |
120 | + | |
121 | + self.assertEquals(self.answer, PostAnswer.objects.all()[0]) | |
122 | + | |
123 | + def test_delete_answer_post (self): | |
124 | + answer = PostAnswer.objects.get(user=self.user_student, post=self.post_professor) | |
125 | + self.answer.delete() | |
126 | + | |
127 | + try: | |
128 | + answer = PostAnswer.objects.get(user=self.user_student, post=self.post_professor) | |
129 | + except: | |
130 | + pass | |
0 | 131 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,106 @@ |
1 | +from django.test import TestCase, Client | |
2 | +from django.core.urlresolvers import reverse | |
3 | +from rolepermissions.shortcuts import assign_role | |
4 | + | |
5 | +from users.models import User | |
6 | +from courses.models import Category, Course, Subject, Topic | |
7 | +from forum.models import Forum | |
8 | + | |
9 | +class ForumTestCase (TestCase): | |
10 | + | |
11 | + def setUp(self): | |
12 | + self.user_professor = User.objects.create_user( | |
13 | + username = 'professor', | |
14 | + email = 'professor@amadeus.com', | |
15 | + is_staff = False, | |
16 | + is_active = True, | |
17 | + password = 'testing', | |
18 | + type_profile = 1 | |
19 | + ) | |
20 | + assign_role(self.user_professor, 'professor') | |
21 | + | |
22 | + self.user_student = User.objects.create_user( | |
23 | + username = 'student', | |
24 | + email = 'student@amadeus.com', | |
25 | + is_staff = False, | |
26 | + is_active = True, | |
27 | + password = 'testing', | |
28 | + type_profile = 2 | |
29 | + ) | |
30 | + assign_role(self.user_student, 'student') | |
31 | + | |
32 | + self.category = Category.objects.create( | |
33 | + name = 'Categoria Teste', | |
34 | + slug = 'categoria_teste' | |
35 | + ) | |
36 | + self.category.save() | |
37 | + | |
38 | + self.course = Course.objects.create( | |
39 | + name = 'Curso Teste', | |
40 | + slug = 'curso_teste', | |
41 | + max_students = 50, | |
42 | + init_register_date = '2016-08-26', | |
43 | + end_register_date = '2016-10-01', | |
44 | + init_date = '2016-10-05', | |
45 | + end_date = '2017-10-05', | |
46 | + category = self.category | |
47 | + ) | |
48 | + self.course.save() | |
49 | + | |
50 | + self.subject = Subject.objects.create( | |
51 | + name = 'Subject Test', | |
52 | + description = "description of the subject test", | |
53 | + visible = True, | |
54 | + course = self.course, | |
55 | + init_date = '2016-10-05', | |
56 | + end_date = '2017-10-05', | |
57 | + ) | |
58 | + self.subject.save() | |
59 | + self.subject.professors.add(self.user_professor) | |
60 | + | |
61 | + self.topic = Topic.objects.create( | |
62 | + name = 'Topic Test', | |
63 | + description = "description of the topic test", | |
64 | + subject = self.subject, | |
65 | + owner = self.user_professor, | |
66 | + ) | |
67 | + self.topic.save() | |
68 | + | |
69 | + self.forum = Forum.objects.create( | |
70 | + topic=self.topic, | |
71 | + name = 'forum test', | |
72 | + description = 'description of the forum test', | |
73 | + create_date = '2016-10-02', | |
74 | + modification_date = '2016-10-03', | |
75 | + limit_date = '2017-10-05', | |
76 | + ) | |
77 | + self.forum.save() | |
78 | + | |
79 | + def test_create_forum (self): | |
80 | + forum = Forum.objects.create( | |
81 | + topic=self.topic, | |
82 | + name = 'forum test2', | |
83 | + description = 'description of the forum test', | |
84 | + create_date = '2016-10-02', | |
85 | + modification_date = '2016-10-03', | |
86 | + limit_date = '2017-10-05', | |
87 | + ) | |
88 | + forum.save() | |
89 | + | |
90 | + self.assertEquals(forum, Forum.objects.filter(name='forum test2')[0]) | |
91 | + | |
92 | + def test_update_forum(self): | |
93 | + self.forum.name = 'forum test updated' | |
94 | + self.forum.save() | |
95 | + | |
96 | + self.assertEquals(self.forum, Forum.objects.get(name='forum test updated')) | |
97 | + | |
98 | + def test_delete_forum (self): | |
99 | + forum = Forum.objects.get(name='forum test') | |
100 | + self.forum.delete() | |
101 | + | |
102 | + try: | |
103 | + forum = Forum.objects.get(name='forum test') | |
104 | + except: | |
105 | + pass | |
106 | + | |
0 | 107 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,148 @@ |
1 | +from django.test import TestCase | |
2 | +from rolepermissions.shortcuts import assign_role | |
3 | + | |
4 | +from users.models import User | |
5 | +from courses.models import Category, Course, Subject, Topic | |
6 | +from forum.models import Forum, Post | |
7 | + | |
8 | +class PostTestCase (TestCase): | |
9 | + | |
10 | + def setUp (self): | |
11 | + self.user_professor = User.objects.create_user( | |
12 | + username = 'professor', | |
13 | + email = 'professor@amadeus.com', | |
14 | + is_staff = False, | |
15 | + is_active = True, | |
16 | + password = 'testing', | |
17 | + type_profile = 1 | |
18 | + ) | |
19 | + assign_role(self.user_professor, 'professor') | |
20 | + | |
21 | + self.user_student = User.objects.create_user( | |
22 | + username = 'student', | |
23 | + email = 'student@amadeus.com', | |
24 | + is_staff = False, | |
25 | + is_active = True, | |
26 | + password = 'testing', | |
27 | + type_profile = 2 | |
28 | + ) | |
29 | + assign_role(self.user_student, 'student') | |
30 | + | |
31 | + self.category = Category.objects.create( | |
32 | + name = 'Categoria Teste', | |
33 | + slug = 'categoria_teste' | |
34 | + ) | |
35 | + self.category.save() | |
36 | + | |
37 | + self.course = Course.objects.create( | |
38 | + name = 'Curso Teste', | |
39 | + slug = 'curso_teste', | |
40 | + max_students = 50, | |
41 | + init_register_date = '2016-08-26', | |
42 | + end_register_date = '2016-10-01', | |
43 | + init_date = '2016-10-05', | |
44 | + end_date = '2017-10-05', | |
45 | + category = self.category | |
46 | + ) | |
47 | + self.course.save() | |
48 | + | |
49 | + self.subject = Subject.objects.create( | |
50 | + name = 'Subject Test', | |
51 | + description = "description of the subject test", | |
52 | + visible = True, | |
53 | + course = self.course, | |
54 | + init_date = '2016-10-05', | |
55 | + end_date = '2017-10-05', | |
56 | + ) | |
57 | + self.subject.save() | |
58 | + self.subject.professors.add(self.user_professor) | |
59 | + | |
60 | + self.topic = Topic.objects.create( | |
61 | + name = 'Topic Test', | |
62 | + description = "description of the topic test", | |
63 | + subject = self.subject, | |
64 | + owner = self.user_professor, | |
65 | + ) | |
66 | + self.topic.save() | |
67 | + | |
68 | + self.forum = Forum.objects.create( | |
69 | + topic=self.topic, | |
70 | + name = 'forum test', | |
71 | + description = 'description of the forum test', | |
72 | + create_date = '2016-10-02', | |
73 | + modification_date = '2016-10-03', | |
74 | + limit_date = '2017-10-05', | |
75 | + ) | |
76 | + self.forum.save() | |
77 | + | |
78 | + self.post_professor = Post.objects.create( | |
79 | + user = self.user_professor, | |
80 | + message = 'posting a test on forum as professor', | |
81 | + modification_date = '2016-11-09', | |
82 | + post_date = '2016-10-03', | |
83 | + forum = self.forum, | |
84 | + ) | |
85 | + self.post_professor.save() | |
86 | + | |
87 | + self.post_student = Post.objects.create( | |
88 | + user = self.user_student, | |
89 | + message = 'posting a test on forum as student', | |
90 | + modification_date = '2016-11-09', | |
91 | + post_date = '2016-10-03', | |
92 | + forum = self.forum, | |
93 | + ) | |
94 | + self.post_student.save() | |
95 | + | |
96 | + def test_create_post_professor (self): | |
97 | + post_professor = Post.objects.create( | |
98 | + user = self.user_professor, | |
99 | + message = 'posting', | |
100 | + modification_date = '2016-11-09', | |
101 | + post_date = '2016-10-03', | |
102 | + forum = self.forum, | |
103 | + ) | |
104 | + post_professor.save() | |
105 | + | |
106 | + self.assertEquals (post_professor, Post.objects.get(user=self.user_professor, message='posting')) | |
107 | + | |
108 | + def test_create_post_student (self): | |
109 | + post_student = Post.objects.create( | |
110 | + user = self.user_student, | |
111 | + message = 'posting', | |
112 | + modification_date = '2016-11-09', | |
113 | + post_date = '2016-10-03', | |
114 | + forum = self.forum, | |
115 | + ) | |
116 | + post_student.save() | |
117 | + | |
118 | + self.assertEquals (post_student, Post.objects.get(user=self.user_student, message='posting')) | |
119 | + | |
120 | + def test_update_post_professor (self): | |
121 | + self.post_professor.message = 'updating a post as professor' | |
122 | + self.post_professor.save() | |
123 | + | |
124 | + self.assertEquals(self.post_professor, Post.objects.all()[1]) | |
125 | + | |
126 | + def test_update_post_student (self): | |
127 | + self.post_student.message = 'updating a post as student' | |
128 | + self.post_student.save() | |
129 | + | |
130 | + self.assertEquals(self.post_student, Post.objects.all()[1]) | |
131 | + | |
132 | + def test_delete_post_professor (self): | |
133 | + post = Post.objects.get(user=self.user_professor, message='posting a test on forum as professor') | |
134 | + self.post_professor.delete() | |
135 | + | |
136 | + try: | |
137 | + post = Post.objects.get(user=self.user_professor, message='posting a test on forum as professor') | |
138 | + except: | |
139 | + pass | |
140 | + | |
141 | + def test_delete_post_student (self): | |
142 | + post = Post.objects.get(user=self.user_student, message='posting a test on forum as student') | |
143 | + self.post_student.delete() | |
144 | + | |
145 | + try: | |
146 | + post = Post.objects.get(user=self.user_student, message='posting a test on forum as student') | |
147 | + except: | |
148 | + pass | |
0 | 149 | \ No newline at end of file | ... | ... |
forum/tests/test_models.py
... | ... | @@ -1,80 +0,0 @@ |
1 | -from django.test import TestCase, Client | |
2 | -from django.core.urlresolvers import reverse | |
3 | -from rolepermissions.shortcuts import assign_role | |
4 | - | |
5 | -from users.models import User | |
6 | -from courses.models import Category, Course, Subject, Topic | |
7 | -from forum.models import Forum | |
8 | - | |
9 | -class ForumTestCase (TestCase): | |
10 | - | |
11 | - def setUp(self): | |
12 | - self.user_professor = User.objects.create_user( | |
13 | - username = 'professor', | |
14 | - email = 'professor@amadeus.com', | |
15 | - is_staff = False, | |
16 | - is_active = True, | |
17 | - password = 'testing', | |
18 | - type_profile = 1 | |
19 | - ) | |
20 | - assign_role(self.user_professor, 'professor') | |
21 | - | |
22 | - self.user_student = User.objects.create_user( | |
23 | - username = 'student', | |
24 | - email = 'student@amadeus.com', | |
25 | - is_staff = False, | |
26 | - is_active = True, | |
27 | - password = 'testing', | |
28 | - type_profile = 2 | |
29 | - ) | |
30 | - assign_role(self.user_student, 'student') | |
31 | - | |
32 | - self.category = Category.objects.create( | |
33 | - name = 'Categoria Teste', | |
34 | - slug = 'categoria_teste' | |
35 | - ) | |
36 | - self.category.save() | |
37 | - | |
38 | - self.course = Course.objects.create( | |
39 | - name = 'Curso Teste', | |
40 | - slug = 'curso_teste', | |
41 | - max_students = 50, | |
42 | - init_register_date = '2016-08-26', | |
43 | - end_register_date = '2016-10-01', | |
44 | - init_date = '2016-10-05', | |
45 | - end_date = '2017-10-05', | |
46 | - category = self.category | |
47 | - ) | |
48 | - self.course.save() | |
49 | - | |
50 | - self.subject = Subject.objects.create( | |
51 | - name = 'Subject Test', | |
52 | - description = "description of the subject test", | |
53 | - visible = True, | |
54 | - course = self.course, | |
55 | - init_date = '2016-10-05', | |
56 | - end_date = '2017-10-05', | |
57 | - ) | |
58 | - self.subject.save() | |
59 | - self.subject.professors.add(self.user_professor) | |
60 | - | |
61 | - self.topic = Topic.objects.create( | |
62 | - name = 'Topic Test', | |
63 | - description = "description of the topic test", | |
64 | - subject = self.subject, | |
65 | - owner = self.user_professor, | |
66 | - ) | |
67 | - self.topic.save() | |
68 | - | |
69 | - def test_create_forum (self): | |
70 | - forum = Forum.objects.create( | |
71 | - topic=self.topic, | |
72 | - name = 'forum test', | |
73 | - description = 'description of the forum test', | |
74 | - create_date = '2016-10-02', | |
75 | - modification_date = '2016-10-03', | |
76 | - limit_date = '2017-10-05', | |
77 | - ) | |
78 | - forum.save() | |
79 | - | |
80 | - self.assertEquals(forum, Forum.objects.all()[0]) | |
81 | 0 | \ No newline at end of file |
requirements.txt
1 | 1 | click==6.6 |
2 | +deps==0.1.0 | |
3 | +dj-database-url==0.4.1 | |
2 | 4 | Django==1.10 |
3 | 5 | django-autoslug==1.9.3 |
4 | 6 | django-bootstrap-breadcrumbs==0.8 |
... | ... | @@ -12,6 +14,7 @@ itsdangerous==0.24 |
12 | 14 | Jinja2==2.8 |
13 | 15 | MarkupSafe==0.23 |
14 | 16 | Pillow==3.3.1 |
17 | +pkg-resources==0.0.0 | |
15 | 18 | psycopg2==2.6.2 |
16 | 19 | pycpfcnpj==1.0.2 |
17 | 20 | six==1.10.0 | ... | ... |
users/tests.py
... | ... | @@ -4,31 +4,60 @@ from django.core.urlresolvers import reverse |
4 | 4 | from .models import * |
5 | 5 | from .forms import * |
6 | 6 | |
7 | -# Create your tests here. | |
8 | -# class TestCreateUser(TestCase): | |
9 | - | |
10 | -# def setUp(self): | |
11 | -# self.client = Client() | |
12 | - | |
13 | -# self.user = User.objects.create_user( | |
14 | -# username = 'test', | |
15 | -# email = 'testing@amadeus.com', | |
16 | -# is_staff = True, | |
17 | -# is_active = True, | |
18 | -# password = 'testing' | |
19 | -# ) | |
20 | -# assign_role(self.user, 'system_admin') | |
21 | - | |
22 | -# def test_edit_users(self): | |
23 | -# self.client.login(username='test', password='testing') | |
24 | - | |
25 | -# url = reverse('users:edit_profile', kwargs={'username': self.user.username}) | |
26 | -# data = EditUserForm().data | |
27 | -# data['email'] = "testing2@amadeus.com" | |
28 | - | |
29 | -# # response = self.client.put(url, data, format='json') | |
30 | -# self.assertEqual(response.status_code, 200) | |
31 | -# self.assertEqual(response.data['email'], data['email']) | |
7 | +#Create your tests here. | |
8 | +class TestUserCase(TestCase): | |
9 | + | |
10 | + def setUp(self): | |
11 | + self.client = Client() | |
12 | + | |
13 | + self.user = User.objects.create_user( | |
14 | + username = 'test', | |
15 | + email = 'testing@amadeus.com', | |
16 | + is_staff = True, | |
17 | + is_active = True, | |
18 | + password = 'testing' | |
19 | + ) | |
20 | + assign_role(self.user, 'system_admin') | |
21 | + | |
22 | + # def test_edit_users(self): | |
23 | + # self.client.login(username='test', password='testing') | |
24 | + | |
25 | + # url = reverse('users:edit_profile', kwargs={'username': self.user.username}) | |
26 | + # data = EditUserForm().data | |
27 | + # data['email'] = "testing2@amadeus.com" | |
28 | + | |
29 | + # response = self.client.put(url, data, format='json') | |
30 | + # self.assertEqual(response.status_code, 200) | |
31 | + # self.assertEqual(response.data['email'], data['email']) | |
32 | + | |
33 | + def test_delete_users(self): | |
34 | + self.user1 = User.objects.create_user( | |
35 | + username = "user1", | |
36 | + email = 'user1@user1.com', | |
37 | + password = 'user1test', | |
38 | + cpf = '11111111111' | |
39 | + ) | |
40 | + self.user2 = User.objects.create_user( | |
41 | + username = "user2", | |
42 | + email = 'user2@user2.com', | |
43 | + password = 'user2test', | |
44 | + cpf = '53574660332' | |
45 | + ) | |
46 | + self.user3 = User.objects.create_user( | |
47 | + username = "user3", | |
48 | + email = 'user3@user3.com', | |
49 | + password = 'user3test', | |
50 | + cpf = '63638052281' | |
51 | + ) | |
52 | + self.client.login(username='user', password = 'testing') | |
53 | + users = User.objects.all().count() | |
54 | + url = reverse('users:delete',kwargs={'username': self.user2.username}) | |
55 | + self.assertEqual(User.objects.all().count(),users) #Before deleting | |
56 | + response = self.client.post(url) | |
57 | + self.assertEqual(User.objects.all().count(),users - 1) #After deleting one user, if OK, the user was removed successfully. | |
58 | + | |
59 | + | |
60 | + | |
32 | 61 | |
33 | 62 | |
34 | 63 | ... | ... |