diff options
-rw-r--r-- | askbot/doc/source/changelog.rst | 2 | ||||
-rw-r--r-- | askbot/forms.py | 7 | ||||
-rw-r--r-- | askbot/media/js/post.js | 36 | ||||
-rw-r--r-- | askbot/media/style/style.less | 9 | ||||
-rw-r--r-- | askbot/templates/question.html | 1 | ||||
-rw-r--r-- | askbot/templates/question/javascript.html | 1 | ||||
-rw-r--r-- | askbot/views/writers.py | 1 |
7 files changed, 48 insertions, 9 deletions
diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index 669c48d2..6a0a5fa4 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -8,7 +8,7 @@ Development version Italian, Japanese (requires package textsearch_ja), Norwegian, Portugese, Romanian, Russian, Spanish, Swedish, Turkish. * repost answer as a comment under the previous (older) answer -* minor edit option for question and answer, to suppress email alerts +* minor edit option for question, answer and comments, to suppress email alerts 0.7.48 (Jan 28, 2013) --------------------- diff --git a/askbot/forms.py b/askbot/forms.py index ca31bf54..0fafec53 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -1342,10 +1342,6 @@ class EditAnswerForm(PostAsSomeoneForm, PostPrivatelyForm): else: return False -class EditCommentForm(forms.Form): - comment_id = forms.IntegerField() - suppress_email = SuppressEmailField() - class EditTagWikiForm(forms.Form): text = forms.CharField(required=False) tag_id = forms.IntegerField() @@ -1700,7 +1696,10 @@ class NewCommentForm(forms.Form): post_id = forms.IntegerField() class EditCommentForm(forms.Form): + comment_id = forms.IntegerField() comment = forms.CharField() + suppress_email = SuppressEmailField() + class DeleteCommentForm(forms.Form): comment_id = forms.IntegerField() diff --git a/askbot/media/js/post.js b/askbot/media/js/post.js index bbc4e672..691d504b 100644 --- a/askbot/media/js/post.js +++ b/askbot/media/js/post.js @@ -1495,9 +1495,11 @@ EditCommentForm.prototype.attachTo = function(comment, mode){ //fix up the comment submit button, depending on the mode if (this._type == 'add'){ this._submit_btn.html(gettext('add comment')); + this._minorEditBox.hide(); } else { this._submit_btn.html(gettext('save comment')); + this._minorEditBox.show(); } //enable the editor this.getElement().show(); @@ -1616,14 +1618,32 @@ EditCommentForm.prototype.createDom = function(){ * and will be initialized by the attachTo() */ + this._controlsBox = this.makeElement('div'); + div.append(this._controlsBox); + this._text_counter = $('<span></span>').attr('class', 'counter'); - div.append(this._text_counter); + this._controlsBox.append(this._text_counter); this._submit_btn = $('<button class="submit small"></button>'); - div.append(this._submit_btn); + this._controlsBox.append(this._submit_btn); this._cancel_btn = $('<button class="submit small"></button>'); this._cancel_btn.html(gettext('cancel')); - div.append(this._cancel_btn); + this._controlsBox.append(this._cancel_btn); + + //if email alerts are enabled, add a checkbox "suppress_email" + if (askbot['settings']['enableEmailAlerts'] === true) { + this._minorEditBox = this.makeElement('div'); + this._controlsBox.append(this._minorEditBox); + var checkBox = this.makeElement('input'); + checkBox.attr('type', 'checkbox'); + checkBox.attr('name', 'suppress_email'); + this._minorEditBox.append(checkBox); + var label = this.makeElement('label'); + label.attr('for', 'suppress_email'); + label.html(gettext("minor edit (don't send alerts)")); + this._minorEditBox.append(label); + } + }; EditCommentForm.prototype.isEnabled = function() { @@ -1658,6 +1678,14 @@ EditCommentForm.prototype.confirmAbandon = function(){ return answer; }; +EditCommentForm.prototype.getSuppressEmail = function() { + return this._element.find('input[name="suppress_email"]').is(':checked'); +}; + +EditCommentForm.prototype.setSuppressEmail = function(bool) { + this._element.find('input[name="suppress_email"]').prop('checked', bool); +}; + EditCommentForm.prototype.getSaveHandler = function(){ var me = this; @@ -1695,6 +1723,8 @@ EditCommentForm.prototype.getSaveHandler = function(){ if (me._type == 'edit'){ post_data['comment_id'] = me._comment.getId(); post_url = askbot['urls']['editComment']; + post_data['suppress_email'] = me.getSuppressEmail(); + me.setSuppressEmail(false); } else { post_data['post_type'] = me._comment.getParentType(); diff --git a/askbot/media/style/style.less b/askbot/media/style/style.less index f5fc98ef..0857f551 100644 --- a/askbot/media/style/style.less +++ b/askbot/media/style/style.less @@ -2338,6 +2338,15 @@ ul#related-tags li { vertical-align: top; width: 100px; } + + input[name="suppress_email"] { + margin: 4px 5px 0 0; + width: auto; + } + label[for="suppress_email"] { + vertical-align: top; + } + button{ line-height:25px; margin: 0 10px 5px -2px; diff --git a/askbot/templates/question.html b/askbot/templates/question.html index b7410a17..9b1f8a6c 100644 --- a/askbot/templates/question.html +++ b/askbot/templates/question.html @@ -262,4 +262,3 @@ </script> #} {% endblock %} - diff --git a/askbot/templates/question/javascript.html b/askbot/templates/question/javascript.html index 665bdbac..55f294c7 100644 --- a/askbot/templates/question/javascript.html +++ b/askbot/templates/question/javascript.html @@ -30,6 +30,7 @@ {% endif %} askbot['settings']['minRepToPostComment'] = {{ settings.MIN_REP_TO_LEAVE_COMMENTS }}; askbot['settings']['tagSource'] = '{{ settings.TAG_SOURCE }}'; + askbot['settings']['enableEmailAlerts'] = {% if settings.ENABLE_EMAIL_ALERTS %}true{% else %}false{% endif %}; </script> <script type="text/javascript" src='{{"/bootstrap/js/bootstrap.js"|media}}'></script> {% if settings.EDITOR_TYPE == 'markdown' %} diff --git a/askbot/views/writers.py b/askbot/views/writers.py index 328ba501..f886b7a6 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -702,6 +702,7 @@ def post_comments(request):#generic ajax handler to load comments to an object @decorators.ajax_only #@decorators.check_spam('comment') def edit_comment(request): + if request.user.is_anonymous(): raise exceptions.PermissionDenied(_('Sorry, anonymous users cannot edit comments')) |