Skip to content

added check for comment length #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions junction/profiles/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class ProfileAdmin(admin.ModelAdmin):
list_display = ('user', 'city', 'contact_no')
search_fields = ('contact_no', 'city')


admin.site.register(Profile, ProfileAdmin)
19 changes: 18 additions & 1 deletion junction/templates/proposals/detail/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h5 class="text-muted clear-margin vote-count">
{% bootstrap_field proposal_comment_form.reviewer %}

{% buttons %}
<button type="submit" class="btn btn-primary">
<button type="button" id="comment" class="btn btn-primary">
Add Comment
</button>
<button type="button" class="btn btn-default js-hide-comment-form">Cancel</button>
Expand Down Expand Up @@ -138,6 +138,23 @@ <h5 class="text-muted clear-margin vote-count">
location.reload(true);
});
});
$("textarea").keypress(function(){
$(".alert").remove()
var text = $("textarea").val();
if (text.length<15) {
$(this).after("<p class='alert alert-warning'><strong>Remember! </strong>Length should be greater than 15!</p>");
}
})

$("#comment").click(function() {
$(".alert").remove()
var text = $("textarea").val();
if (text.length >= 15) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make 15 as a variable and this variable needs to configurable via the Django settings and must not be hard-coded into template.

$("form").submit();
} else {
$("textarea").after("<p class='alert alert-danger'><strong>Oops! </strong>Length should be greater than 15.</p>");
}
})

{% else %}
$('.js-proposal-upvote, .js-proposal-downvote, .js-proposal-comment-upvote, .js-proposal-comment-downvote').click(function(e){
Expand Down
2 changes: 1 addition & 1 deletion settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"junction.base.context_processors.site_info",
],

'debug': DEBUG,
'debug': DEBUG, # noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't it requires a # noqa here, can you provide the actual error message you are getting.

},
},
]
Expand Down
6 changes: 3 additions & 3 deletions settings/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(ROOT_DIR, 'test.sqlite3'),
'NAME': os.path.join(ROOT_DIR, 'test.sqlite3'), # noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't it requires a # noqa here, can you provide the actual error message you are getting.

}
}

TEMPLATE_CONTEXT_PROCESSORS += (
TEMPLATE_CONTEXT_PROCESSORS += ( # noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't it requires a # noqa here, can you provide the actual error message you are getting.

"django.core.context_processors.debug",
)

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

INSTALLED_APPS += ('django_extensions',)
INSTALLED_APPS += ('django_extensions',) # noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix this, you need to follow PEP8 guideline, which says there should be a space after comma in a tuple. You can remove the #noqa and fix the actual issue.


DEVICE_VERIFICATION_CODE = 11111
2 changes: 1 addition & 1 deletion tests/integrations/test_reviewer_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_reviewer_private_comment(self, settings, login, conferences,
data = {'comment': 'Test', 'private': True}

response = client.post(url, data)

print(response.url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the print from here.

assert response.status_code == 302
assert response.url.endswith('#js-reviewers')

Expand Down