wenqin got a fish trophy!
add tips feature for reviewboard motd extension
Review Request #10001 — Created June 6, 2018 and discarded
This change makes motd (message of the day) extension more useful by providing with a tips feature. Admin can manually add tips, or uploading a text file with tips, and it would display a random tip below the message of the day banner.
Tested in local environment
Description | From | Last Updated |
---|---|---|
E203 whitespace before ':' |
reviewbot | |
E203 whitespace before ':' |
reviewbot | |
E231 missing whitespace after ':' |
reviewbot | |
E231 missing whitespace after ':' |
reviewbot | |
E203 whitespace before ':' |
reviewbot | |
E203 whitespace before ':' |
reviewbot | |
E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
W391 blank line at end of file |
reviewbot | |
F401 'django.utils.six.moves.range' imported but unused |
reviewbot | |
W391 blank line at end of file |
reviewbot | |
W292 no newline at end of file |
reviewbot | |
W292 no newline at end of file |
reviewbot | |
tips_file |
solarmist | |
Probably don't want to allow empty files. |
solarmist | |
Load tips file. One line per tip. If using HTML it must be properly escaped. |
solarmist | |
tips_file |
solarmist | |
I think this is all you need class ListEditWidgetWithClearButton(ListEditWidget): template_name = 'rbmotd/list_edit_widget_with_clear_button.html' |
solarmist | |
Not needed. |
solarmist | |
Are there any changes to this? It doesn't seems like it, but the code has changed. https://github.com/djblets/djblets/blob/master/djblets/forms/widgets.py |
solarmist | |
There are no changes on this function. I copied the codes over from ListEditWidget class from this file: https://github.com/djblets/djblets/blob/master/djblets/forms/widgets.py |
wenqin | |
Not needed. |
solarmist | |
Look into less. I think this can re-use most of #motd-close #motd { ... } #motd-close { background: @bg-color-tip; } |
solarmist | |
I tried before and that did not work. I think the only two way to reuse a component is (1) … |
wenqin | |
Just add this to the existing one. |
solarmist | |
Just add this to the existing one. |
solarmist | |
Indentation should be 4 spaces. |
solarmist | |
Please add a comment block like https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js |
solarmist | |
Comment block. https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js |
solarmist | |
Not needed. |
solarmist | |
Comment why are you seperating this? |
solarmist | |
Not needed. |
solarmist | |
Unneeded blank. |
solarmist | |
Comment block https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js |
solarmist | |
Ditto. |
solarmist | |
Comment block https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js |
solarmist | |
blank line between these |
solarmist | |
Comment block https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js |
solarmist | |
Blank line |
solarmist | |
Instead of a for loop use: tips.forEach{} https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach |
solarmist | |
https://api.jquery.com/last/ |
solarmist | |
Use a variable to store this then manipulate it. |
solarmist | |
Comment block. |
solarmist | |
You can filter better so you don't need to use a for loop. Then use $.each(function(){$this.click()}. https://stackoverflow.com/questions/10651349/how-to-select-empty-inputs-value-using-jquery?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa |
solarmist | |
4 spaces for JS code. |
solarmist | |
Can we just make this two functions where we pass in {{motd_close_value}} or the new one and '#modt' or '#motd-tip', … |
solarmist | |
Make this a small block along with the motd one and move it to the top and keep the JS … |
solarmist | |
4 spaces for JS code. |
solarmist | |
I'd make this part of the code that checks the cookie. |
solarmist | |
Unneeded new lines. |
solarmist | |
Comment block |
solarmist | |
Shouldn't be needed if using .forEach |
solarmist | |
.forEach |
solarmist | |
I feel like this could be cleaner, but I'm not positive, but otherwise please add a comment about why this … |
solarmist | |
Comment block. Mention that this is to handle windows newlines. |
solarmist | |
Extra whitespace? Look at the original files and try to match the style that's already there. |
solarmist | |
E501 line too long (136 > 79 characters) |
reviewbot | |
E501 line too long (86 > 79 characters) |
reviewbot | |
E501 line too long (83 > 79 characters) |
reviewbot | |
If this doesn't have any code changes it isn't needed, it'll just re-use the method from ListEditWidget. |
solarmist |
- Commit:
-
6118a7c0e06d69c0f1caca2dfab639863d7169794dfc9616caab8b342762bf926e1ce28527df3b4a
- Diff:
-
Revision 2 (+307 -3)
- Commit:
-
4dfc9616caab8b342762bf926e1ce28527df3b4a71851cfa4a069283c15968c6a4d11ea6fd6c6396
- Diff:
-
Revision 3 (+307 -3)
Checks run (1 succeeded, 1 failed with error)
- Description:
-
~ add tips feature for reviewboard motd extension
~ This change makes motd (message of the day) extension more useful by providing with a tips feature. Admin can manually add tips, or uploading a text file with tips, and it would display a random tip below the message of the day banner.
-
-
-
-
-
-
This is mostly a copy paste extension of the existing list_edit_widget, but the code lives in Djblets so it needed to be duplicated here.
-
I think this is all you need
class ListEditWidgetWithClearButton(ListEditWidget): template_name = 'rbmotd/list_edit_widget_with_clear_button.html'
-
-
Are there any changes to this? It doesn't seems like it, but the code has changed.
https://github.com/djblets/djblets/blob/master/djblets/forms/widgets.py
-
-
Look into less. I think this can re-use most of
#motd-close #motd { ... } #motd-close { background: @bg-color-tip; }
-
-
-
-
Please add a comment block like
https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js -
Comment block.
https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js
-
-
-
-
-
Comment block
https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js -
-
Comment block
https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js -
-
Comment block
https://github.com/djblets/djblets/blob/master/djblets/static/djblets/js/forms/views/listEditView.es6.js -
-
Instead of a for loop use:
tips.forEach{}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
-
-
-
-
You can filter better so you don't need to use a for loop. Then use
$.each(function(){$this.click()}
.https://stackoverflow.com/questions/10651349/how-to-select-empty-inputs-value-using-jquery?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
-
-
-
-
Can we just make this two functions where we pass in
{{motd_close_value}}
or the new one and'#modt'
or'#motd-tip'
, etc. -
Make this a small block along with the motd one and move it to the top and keep the JS code at the bottom.
-
-
-
-
-
-
-
I feel like this could be cleaner, but I'm not positive, but otherwise please add a comment about why this is needed.
-
-
-
-
There are no changes on this function. I copied the codes over from ListEditWidget class from this file:
https://github.com/djblets/djblets/blob/master/djblets/forms/widgets.py -
I tried before and that did not work.
I think the only two way to reuse a component is
(1) define a mixing and pass in variables
(2) extension.
- Commit:
-
71851cfa4a069283c15968c6a4d11ea6fd6c63968d8c3f79c8fd0397e354bb844549f52e873f9816
- Diff:
-
Revision 4 (+318 -17)
-
Looks good to me.
-
Try this.
help_text=_('Load tips file. One line per tip. ' 'This field expects valid text file. ' 'If using HTML it must be properly escaped.')
-
I think I'd make some variables for message, tips and tips_file. That'll take care of the lines too long.
-
If this doesn't have any code changes it isn't needed, it'll just re-use the method from ListEditWidget.
-