Skip to content
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

Fix issues with multilanguage news #1354

Merged
merged 1 commit into from
Apr 10, 2024
Merged

Conversation

mikaelGusse
Copy link
Contributor

Description

What?

Removed two leftover print calls and changed how the singular news remove button functions. Previously the button was sending a GET request which then edited the database which should not be done. This has now been changed such that it send a POST request instead.

Why?

Improves code readability and functionality

How?

Added a javascript listener to the singular remove buttons that then sends the request and redirects back to the current page

Testing

Remember to add or update unit tests for new features and changes.

What type of test did you run?

  • Accessibility test using the WAVE extension.
  • Django unit tests.
  • Selenium tests.
  • Other test. (Add a description below)
  • Manual testing.

Tried removing news in different kinds of situations (Just one news item, multiple, last news item, one from the middle etc.)

Did you test the changes in

  • Chrome
  • Firefox
  • This pull request cannot be tested in the browser.

Think of what is affected by these changes and could become broken

Translation

Programming style

  • Did you follow our style guides?
  • Did you use Python type hinting in all functions that you added or edited? (type hints for function parameters and return values)

Have you updated the README or other relevant documentation?

  • documents inside the doc directory.
  • README.md.
  • Aplus Manual.
  • Other documentation (mention below which documentation).

Is it Done?

  • Reviewer has finished the code review
  • After the review, the developer has made changes accordingly
  • Customer/Teacher has accepted the implementation of the feature

Clean up your git commit history before submitting the pull request!

@ihalaij1 ihalaij1 self-requested a review April 8, 2024 10:51
@ihalaij1 ihalaij1 self-assigned this Apr 8, 2024
Copy link
Contributor

@ihalaij1 ihalaij1 left a comment

Choose a reason for hiding this comment

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

I commented on a few minor things.

fetch(currentUrl + newsId + '/remove/', {
method: 'POST',
headers: {
'X-CSRFToken': '{{ csrf_token }}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comma after 'X-CSRFToken': '{{ csrf_token }}'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 82 to 89
var removeBtns = document.querySelectorAll("[id^='remove-btn']");

for (var i = 0; i < removeBtns.length; i++) {
removeBtns[i].addEventListener('click', function(event) {
event.preventDefault();

var currentUrl = window.location.href;
var newsId = this.getAttribute('value');
Copy link
Contributor

Choose a reason for hiding this comment

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

Only use var if it is needed, I think const and let should be enough in this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything is now const except the interator in the for loop which is now let

@ihalaij1 ihalaij1 merged commit 8183af8 into apluslms:master Apr 10, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants