Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rwfalcao committed Apr 6, 2018
2 parents 2152a50 + d3f7fb9 commit f481ed0
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 84 deletions.
3 changes: 2 additions & 1 deletion ideax/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.contrib import admin
from .models import Idea, UserProfile, Popular_Vote, Comment
from .models import Idea, UserProfile, Popular_Vote, Comment, Category

admin.site.register(Idea)
admin.site.register(UserProfile)
admin.site.register(Popular_Vote)
admin.site.register(Comment)
admin.site.register(Category)
15 changes: 1 addition & 14 deletions ideax/static/js/idea.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ function vote(url, idLike, idDislike, aLike, aDislike){
}

$(function () {


var teste = function() {
var length = $("#id_oportunity").val().length + $("#id_solution").val().length + $("#id_target").val().length;
$("#character_count").html(length+"/3000")

}

$(document).on("keyup", "#id_oportunity", teste);
$(document).on("keyup", "#id_solution", teste);
$(document).on("keyup", "#id_target", teste);


var loadForm = function(){
var btn = $(this);
var idModal = btn.attr("data-modal");
Expand Down Expand Up @@ -221,7 +208,7 @@ $(document).on("keyup", "#id_target", teste);
</div>\
<div class="form-group">\
<div class="col-lg-10 col-lg-offset-2">\
<button type="submit" class="btn btn-primary">Submit</button>\
<button type="submit" class="btn btn-primary">Comentar</button>\
</div>\
</div>\
</fieldset>\
Expand Down
1 change: 0 additions & 1 deletion ideax/templates/ideax/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<html>
<head>
<title>Ideia X</title>
<link href='//fonts.googleapis.com/css?family=Lobster&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="{% static 'css/idea.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion ideax/templates/ideax/idea_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ul>
</nav>
{% for message in messages %}
<div class="alert alert-dismissible alert-{{ message.tags }}">
<div class="alert alert-dismissible alert-{% if message.tags == 'error' %}danger{%else%}{{message.tags}}{%endif%}">
<button type="button" class="close" data-dismiss="alert">×</button>
{{ message }}
</div>
Expand Down
4 changes: 4 additions & 0 deletions ideax/templates/ideax/includes/idea_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ <h1 class="idea-title" data-toggle="tooltip" data-placement="bottom" title="{{ i
{% endif%} -->

<!-- idea card phase change and actions -->
{% if idea.id in ideas_created_by_me or request.user.userprofile.manager %}
<div class="idea-options">
<input class="menu-input" type="checkbox" id="menu{{idea.pk}}">
<label for="menu{{idea.pk}}">
Expand All @@ -38,16 +39,19 @@ <h1 class="idea-title" data-toggle="tooltip" data-placement="bottom" title="{{ i
<li><a href="{% url 'change_phase' pk=idea.pk new_phase=7%}">{% trans 'Freezed' %}</a></li>
{% endif %}
<li class="actions">
{% if idea.id in ideas_created_by_me or request.user.userprofile.manager %}
<div class="action edit">
<a class="js-update-idea" href="{% url 'idea_edit' pk=idea.pk %}"><i class="far fa-edit"></i></a>
</div>
<div class="action delete">
<button class="js-remove-idea" data-modal="#modal-idea-crud" data-url="{% url 'idea_remove' pk=idea.pk %}"><i class="far fa-trash-alt"></i></button>
</div>
{%endif%}
</li>
</ul>
</div>
</div>
{%endif%}
</div>
<!-- idea body -->

Expand Down
4 changes: 2 additions & 2 deletions ideax/templates/ideax/includes/partial_comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<div class="media-body">
<div class="mt-0 comment-header">
<span class="c-author">{{ node.author.user}}</span>
<span class="c-date">{{ node.date|date:"d/m/Y h:m"}}</span>
<span class="c-date">{{ node.date|date:"d/m/Y H:m"}}</span>
</div>
<div class="comment-body">
{{ node.raw_comment|safe }}
</div>
<div class="reply-link reply-container">
<a href="javascript:void(0)" data-idea-id="{{idea_id}}" data-parent-id="{{ node.id }}" name="replyButton">reply</a>
<a href="javascript:void(0)" data-idea-id="{{idea_id}}" data-parent-id="{{ node.id }}" name="replyButton">{% trans 'reply' %}</a>
</div>
{% if not node.is_leaf_node %}
<div class="reply">
Expand Down
5 changes: 0 additions & 5 deletions ideax/templates/ideax/includes/partial_idea_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
{% endfor %}
</div>

<div class="form-group">
<label style="text-align: right;">Caracteres digitados: </label>
<p id="character_count" style="text-align: right;">0/3000</p>
</div>

<div class="form-group{% if form.category.errors %} has-error{% endif %}">
<label for="{{form.category.id_for_label}}">{{form.category.label}}</label>
{{ form.category|add_class:'form_control' }}
Expand Down
56 changes: 33 additions & 23 deletions ideax/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def idea_filter(request, phase_pk):
ideas.sort(key=lambda idea:idea.creation_date)
context={'ideas': ideas,
'ideas_liked': get_ideas_voted(request, True),
'ideas_disliked': get_ideas_voted(request, False),}
'ideas_disliked': get_ideas_voted(request, False),
'ideas_created_by_me' : get_ideas_created(request),}

data = dict()
data['html_idea_list'] = render_to_string('ideax/idea_list_loop.html', context, request=request)
Expand All @@ -74,9 +75,8 @@ def save_idea(request, form, template_name, new=False):
if form.is_valid():
idea = form.save(commit=False)

idea.author = UserProfile.objects.get(user=request.user)

if new:
idea.author = UserProfile.objects.get(user=request.user)
idea.creation_date = timezone.now()
idea.phase= Phase.GROW.id
idea.save()
Expand Down Expand Up @@ -106,31 +106,40 @@ def idea_new(request):
@login_required
def idea_edit(request, pk):
idea = get_object_or_404(Idea, pk=pk)
if request.method == "POST":
form = IdeaForm(request.POST, instance=idea)
else:
form = IdeaForm(instance=idea)

return save_idea(request, form, 'ideax/idea_edit.html')
if request.user.userprofile == idea.author or request.user.userprofile.manager:
if request.method == "POST":
form = IdeaForm(request.POST, instance=idea)
else:
form = IdeaForm(instance=idea)

return save_idea(request, form, 'ideax/idea_edit.html')
else:
messages.error(request, _('Not supported action'))
return redirect('index')

@login_required
def idea_remove(request, pk):
idea = get_object_or_404(Idea, pk=pk)
data = dict()
if request.method == 'POST':
idea.discarded = True
idea.save()
data['form_is_valid'] = True
ideas = get_ideas_init(request)
data['html_list'] = render_to_string('ideax/idea_list_loop.html', ideas, request=request)
else:
context = {'idea' : idea}
data['html_form'] = render_to_string('ideax/includes/partial_idea_remove.html',
context,
request=request,)

return JsonResponse(data)
if ((request.user.userprofile == idea.author or request.user.userprofile.manager) and request.is_ajax()):
if request.method == 'POST':
idea.discarded = True
idea.save()
data['form_is_valid'] = True
ideas = get_ideas_init(request)
data['html_list'] = render_to_string('ideax/idea_list_loop.html', ideas, request=request)
else:
context = {'idea' : idea}
data['html_form'] = render_to_string('ideax/includes/partial_idea_remove.html',
context,
request=request,)

return JsonResponse(data)
else:
messages.error(request, _('Not supported action'))
return redirect('index')

@login_required
def criterion_new(request):
Expand Down Expand Up @@ -166,6 +175,7 @@ def criterion_edit(request, pk):
@login_required
def criterion_remove(request, pk):
criterion = get_object_or_404(Criterion, pk=pk)

criterion.delete()
return redirect('criterion_list')

Expand Down Expand Up @@ -288,7 +298,7 @@ def change_idea_phase(request, pk, new_phase):
idea = Idea.objects.get(pk=pk)
phase = Phase.get_phase_by_id(new_phase)

if phase != None:
if phase != None and request.user.userprofile.manager:
phase_history_current = Phase_History.objects.get(idea=idea, current=True)
phase_history_current.current = False
phase_history_current.save()
Expand Down Expand Up @@ -331,8 +341,8 @@ def post_comment(request):
author = UserProfile.objects.get(user=request.user)
idea_id = request.POST.get('ideiaId', None)

if Profanity_Check.wordcheck().blacklisted(raw_comment):
return JsonResponse({'msg': _("Please check your message it has inappropriate content.")}, status=500)
#if Profanity_Check.wordcheck().blacklisted(raw_comment):
# return JsonResponse({'msg': _("Please check your message it has inappropriate content.")}, status=500)

if not raw_comment:
return JsonResponse({'msg': _("You have to write a comment.")},status=500)
Expand Down
40 changes: 22 additions & 18 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ msgid "Weight"
msgstr ""

#: ideax/forms.py:25 ideax/forms.py:32
#: ideax/templates/ideax/includes/idea_detail.html:57
#: ideax/templates/ideax/includes/idea_detail.html:61
#: ideax/templates/ideax/includes/partial_category_list.html:6
msgid "Description"
msgstr ""

#: ideax/templates/ideax/base.html:24
#: ideax/templates/ideax/base.html:23
msgid "New Idea"
msgstr ""

#: ideax/templates/ideax/base.html:29
#: ideax/templates/ideax/base.html:28
#, python-format
msgid "Hi, %(name)s!"
msgstr ""
Expand Down Expand Up @@ -102,32 +102,32 @@ msgid "All"
msgstr ""

#: ideax/templates/ideax/idea_list.html:12
#: ideax/templates/ideax/includes/idea_detail.html:32
#: ideax/templates/ideax/includes/idea_detail.html:33
msgid "Discussion"
msgstr ""

#: ideax/templates/ideax/idea_list.html:13
#: ideax/templates/ideax/includes/idea_detail.html:33
#: ideax/templates/ideax/includes/idea_detail.html:34
msgid "Evaluation"
msgstr ""

#: ideax/templates/ideax/idea_list.html:14
#: ideax/templates/ideax/includes/idea_detail.html:34
#: ideax/templates/ideax/includes/idea_detail.html:35
msgid "Approval"
msgstr ""

#: ideax/templates/ideax/idea_list.html:15
#: ideax/templates/ideax/includes/idea_detail.html:35
#: ideax/templates/ideax/includes/idea_detail.html:36
msgid "Development"
msgstr ""

#: ideax/templates/ideax/idea_list.html:16
#: ideax/templates/ideax/includes/idea_detail.html:36
#: ideax/templates/ideax/includes/idea_detail.html:37
msgid "Finished"
msgstr ""

#: ideax/templates/ideax/idea_list.html:17
#: ideax/templates/ideax/includes/idea_detail.html:37
#: ideax/templates/ideax/includes/idea_detail.html:38
msgid "Archived"
msgstr ""

Expand All @@ -136,7 +136,7 @@ msgstr ""
msgid "Create Idea"
msgstr ""

#: ideax/templates/ideax/includes/idea_detail.html:38
#: ideax/templates/ideax/includes/idea_detail.html:39
msgid "Freezed"
msgstr ""

Expand All @@ -162,6 +162,10 @@ msgstr ""
msgid "Close"
msgstr ""

#: ideax/templates/ideax/includes/partial_comments.html:19
msgid "reply"
msgstr ""

#: ideax/templates/ideax/includes/partial_idea_remove.html:10
msgid "Confirm ideia removal"
msgstr ""
Expand Down Expand Up @@ -259,22 +263,22 @@ msgstr ""
msgid "Idea saved successfully!"
msgstr ""

#: ideax/views.py:303
msgid "Phase change successfully!"
#: ideax/views.py:118 ideax/views.py:141
msgid "Not supported action"
msgstr ""

#: ideax/views.py:327
msgid "You need to log in to post new comments."
#: ideax/views.py:313
msgid "Phase change successfully!"
msgstr ""

#: ideax/views.py:335
msgid "Please check your message it has inappropriate content."
#: ideax/views.py:337
msgid "You need to log in to post new comments."
msgstr ""

#: ideax/views.py:338
#: ideax/views.py:348
msgid "You have to write a comment."
msgstr ""

#: ideax/views.py:356
#: ideax/views.py:366
msgid "Your comment has been posted."
msgstr ""
Loading

0 comments on commit f481ed0

Please sign in to comment.