Commit 94ff89ba0ad3d9da66f943f4277055069d252267
Exists in
master
and in
3 other branches
Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring
Showing
5 changed files
with
32 additions
and
30 deletions
Show diff stats
amadeus/settings.py
... | ... | @@ -242,8 +242,8 @@ LOGS_URL = 'logs/' |
242 | 242 | |
243 | 243 | |
244 | 244 | |
245 | -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | |
246 | -DEFAULT_FROM_EMAIL = 'admin@amadeus.com.br' | |
245 | +# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | |
246 | +# DEFAULT_FROM_EMAIL = 'admin@amadeus.com.br' | |
247 | 247 | |
248 | 248 | # Messages |
249 | 249 | from django.contrib.messages import constants as messages_constants |
... | ... | @@ -256,9 +256,10 @@ MESSAGE_TAGS = { |
256 | 256 | } |
257 | 257 | |
258 | 258 | #Send email for forgot Password |
259 | +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | |
259 | 260 | EMAIL_USE_TLS = True |
260 | -DEFAULT_FROM_EMAIL = 'test@gmail.com' | |
261 | -SERVER_EMAIL = 'test@gmail.com' | |
261 | +DEFAULT_FROM_EMAIL = 'amadeusteste@gmail.com' | |
262 | +# SERVER_EMAIL = 'amadeusteste@gmail.com' | |
262 | 263 | EMAIL_HOST = 'smtp.gmail.com' |
263 | 264 | EMAIL_PORT = 587 |
264 | 265 | EMAIL_HOST_USER = 'amadeusteste@gmail.com' | ... | ... |
topics/forms.py
... | ... | @@ -17,12 +17,12 @@ class TopicForm(forms.ModelForm): |
17 | 17 | def clean_name(self): |
18 | 18 | name = self.cleaned_data.get('name', '') |
19 | 19 | repo = self.cleaned_data.get('repository', False) |
20 | - | |
20 | + | |
21 | 21 | if self.instance.id: |
22 | 22 | same_name = self.subject.topic_subject.filter(name__unaccent__iexact = name).exclude(id = self.instance.id).count() |
23 | 23 | else: |
24 | 24 | same_name = self.subject.topic_subject.filter(name__unaccent__iexact = name).count() |
25 | - | |
25 | + | |
26 | 26 | if same_name > 0: |
27 | 27 | if repo: |
28 | 28 | self._errors['name'] = [_('This subject already has a repository')] |
... | ... | @@ -38,4 +38,4 @@ class TopicForm(forms.ModelForm): |
38 | 38 | fields = ['repository', 'name', 'description', 'visible' ] |
39 | 39 | widgets = { |
40 | 40 | 'description': forms.Textarea, |
41 | - } | |
42 | 41 | \ No newline at end of file |
42 | + } | ... | ... |
topics/templates/resources/list.html
... | ... | @@ -3,15 +3,15 @@ |
3 | 3 | |
4 | 4 | {% subject_permissions request.user topic.subject as has_subject_permissions %} |
5 | 5 | |
6 | -<div id="resource_{{ topic.slug }}" class="list-group resource_list"> | |
6 | +<div id="resource_{{ topic.slug }}_topic" class="list-group resource_list"> | |
7 | 7 | {% for resource in topic.resource_topic.all %} |
8 | 8 | {% resource_permissions request.user resource as has_resource_permissions %} |
9 | - | |
9 | + | |
10 | 10 | {% if has_resource_permissions %} |
11 | 11 | <div class="list-group-item {% if not resource.visible %}disabled{% endif %}"> |
12 | - <input type="hidden" class="id_inp" name="id" value="{{ resource.id }}" /> | |
13 | - <input type="hidden" class="order_inp" name="order" value="{{ resource.order }}" /> | |
14 | - <input type="hidden" class="url_order" value="{% url 'topics:update_resource_order' %}" /> | |
12 | + <input type="hidden" class="id_inp_resource" name="id" value="{{ resource.id }}" /> | |
13 | + <input type="hidden" class="order_inp_resource" name="order" value="{{ resource.order }}" /> | |
14 | + <input type="hidden" class="url_order_resource" value="{% url 'topics:update_resource_order' %}" /> | |
15 | 15 | |
16 | 16 | <h4 class="pull-left list-group-item-heading"> |
17 | 17 | <a data-href="{{ resource.access_link }}" class="resource_link" {% if resource.show_window %}target="_blank"{% endif %}> |
... | ... | @@ -50,7 +50,7 @@ |
50 | 50 | $('.modal').remove(); |
51 | 51 | |
52 | 52 | $.get(url, function (modal) { |
53 | - $("#resource_{{ topic.slug }}").parent().after(modal); | |
53 | + $("#resource_{{ topic.slug }}_topic").parent().after(modal); | |
54 | 54 | |
55 | 55 | $('.modal').modal('show'); |
56 | 56 | }); |
... | ... | @@ -62,7 +62,7 @@ |
62 | 62 | btn = $(this).find('button.btn_menu').is(e.target), |
63 | 63 | del = $(this).find('a.delete').is(e.target), |
64 | 64 | upd = $(this).find('a.edit').is(e.target); |
65 | - | |
65 | + | |
66 | 66 | if (!arrow && !menu && !del && !upd && !btn) { |
67 | 67 | var link = $(this).find('.resource_link').data('href'), |
68 | 68 | target = $(this).find('.resource_link').attr('target'); |
... | ... | @@ -75,19 +75,19 @@ |
75 | 75 | } |
76 | 76 | }); |
77 | 77 | |
78 | - $("#resource_{{ topic.slug }}").sortable({ | |
78 | + $("#resource_{{ topic.slug }}_topic").sortable({ | |
79 | 79 | delay: 100, |
80 | 80 | distance: 5, |
81 | 81 | handle: 'i.fa-arrows', |
82 | 82 | update: function( event, ui ) { |
83 | 83 | var cont = 1; |
84 | 84 | var data = []; |
85 | - | |
86 | - $("#resource_{{ topic.slug }}").find('.order_inp').each(function () { | |
85 | + | |
86 | + $("#resource_{{ topic.slug }}_topic").find('.order_inp_resource').each(function () { | |
87 | 87 | $(this).val(cont++); |
88 | 88 | |
89 | 89 | data.push({ |
90 | - 'resource_id': $(this).parent().find('.id_inp').val(), | |
90 | + 'resource_id': $(this).parent().find('.id_inp_resource').val(), | |
91 | 91 | 'resource_order': $(this).val() |
92 | 92 | }); |
93 | 93 | }); |
... | ... | @@ -100,15 +100,15 @@ |
100 | 100 | |
101 | 101 | function sendUpdateResource(data) { |
102 | 102 | $.ajax({ |
103 | - url: $("#resource_{{ topic.slug }}").find('.url_order').val(), | |
103 | + url: $('.url_order_resource').val(), | |
104 | 104 | dataType: 'json', |
105 | 105 | data: {'data': data}, |
106 | 106 | success: function(response) { |
107 | 107 | console.log(response); |
108 | 108 | }, |
109 | 109 | error: function(response) { |
110 | - console.log(response); | |
110 | + console.log(response); | |
111 | 111 | } |
112 | 112 | }); |
113 | 113 | } |
114 | -</script> | |
115 | 114 | \ No newline at end of file |
115 | +</script> | ... | ... |
topics/views.py
... | ... | @@ -47,7 +47,7 @@ class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
47 | 47 | slug = self.kwargs.get('slug', '') |
48 | 48 | |
49 | 49 | initial['subject'] = get_object_or_404(Subject, slug = slug) |
50 | - | |
50 | + | |
51 | 51 | return initial |
52 | 52 | |
53 | 53 | def form_valid(self, form): |
... | ... | @@ -57,6 +57,7 @@ class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
57 | 57 | subject = get_object_or_404(Subject, slug = slug) |
58 | 58 | |
59 | 59 | self.object.subject = subject |
60 | + print (subject.topic_subject.count()) | |
60 | 61 | self.object.order = subject.topic_subject.count() + 1 |
61 | 62 | |
62 | 63 | self.object.save() |
... | ... | @@ -125,7 +126,7 @@ class UpdateView(LoginRequiredMixin, LogMixin, generic.UpdateView): |
125 | 126 | slug = self.kwargs.get('sub_slug', '') |
126 | 127 | |
127 | 128 | initial['subject'] = get_object_or_404(Subject, slug = slug) |
128 | - | |
129 | + | |
129 | 130 | return initial |
130 | 131 | |
131 | 132 | def get_context_data(self, **kwargs): |
... | ... | @@ -263,7 +264,7 @@ def update_resource_order(request): |
263 | 264 | |
264 | 265 | if not data is None: |
265 | 266 | data = json.loads(data) |
266 | - | |
267 | + | |
267 | 268 | for t_data in data: |
268 | 269 | resource = get_object_or_404(Resource, id = t_data['resource_id']) |
269 | 270 | resource.order = t_data['resource_order'] |
... | ... | @@ -276,7 +277,7 @@ def update_resource_order(request): |
276 | 277 | |
277 | 278 | def getResourceCount(request): |
278 | 279 | resources = Resource.objects.distinct() |
279 | - | |
280 | + | |
280 | 281 | data = {} |
281 | 282 | for resource in resources: |
282 | 283 | key = resource.__dict__['_my_subclass'] |
... | ... | @@ -284,8 +285,8 @@ def getResourceCount(request): |
284 | 285 | data[key] = data[key] + 1 |
285 | 286 | else: |
286 | 287 | data[key] = 1 |
287 | - | |
288 | - real_data = [] | |
288 | + | |
289 | + real_data = [] | |
289 | 290 | for item in data.items(): |
290 | 291 | real_data.append(item) |
291 | 292 | return JsonResponse(real_data, safe=False) | ... | ... |
users/views.py
... | ... | @@ -412,7 +412,7 @@ class ForgotPassword(generic.FormView): |
412 | 412 | subject = ''.join(subject.splitlines()) |
413 | 413 | email = loader.render_to_string(email_template_name, c) |
414 | 414 | |
415 | - mailsender = MailSender.objects.get(id = 1) | |
415 | + mailsender = MailSender.objects.latest('id') | |
416 | 416 | |
417 | 417 | if mailsender.hostname == "example.com": |
418 | 418 | send_mail(subject, email, settings.DEFAULT_FROM_EMAIL , [user.email], fail_silently=False) |
... | ... | @@ -424,10 +424,10 @@ class ForgotPassword(generic.FormView): |
424 | 424 | |
425 | 425 | backend = EmailBackend( |
426 | 426 | host = mailsender.hostname, port = mailsender.port, username = mailsender.username, |
427 | - password = mailsender.password, use_tls = tls, fail_silently = False | |
427 | + password = mailsender.password, use_tls = tls | |
428 | 428 | ) |
429 | 429 | |
430 | - mail_msg = EmailMessage(subject = subject, body = email, from_email = settings.DEFAULT_FROM_EMAIL, to = [user.email], connection = backend) | |
430 | + mail_msg = EmailMessage(subject = subject, body = email, to = [user.email], connection = backend) | |
431 | 431 | |
432 | 432 | mail_msg.send() |
433 | 433 | ... | ... |