EdwinRodger / MyMangaDataBase

Self Hosted Manga Tracker
https://edwinrodger.github.io/MyMangaDataBase/
GNU General Public License v3.0
13 stars 1 forks source link

End Date field is emptied when going to edit if it was set to 01/01/0001 instead of keeping 01/01/0001 #9

Closed Kazer67 closed 4 months ago

Kazer67 commented 4 months ago

Steps to reproduce

Add or Edit a Manga with no End Date (so End Date at 01/01/0001). Save the change. Go back to the Manga list and then go back to said Manga.

EndDate_Empty.webm

Expected behavior

Going to Edit on a Manga with no end date should default to 01/01/0001

Actual behavior

The 01/01/0001 No End Date isn't saved.

MyMangaDataBase version

2.4.0

Other details

The issue doesn't exist when there's an actual End Date specified.

Acknowledgements

EdwinRodger commented 4 months ago

Fixed in 84e9a13c67fbfaed633c2a9d320600f7c82b6638 Also, the date field is always dd-mm-yyyy in linux for some reason.

Another thing, this is Linux specific error, couldn't able to reproduce on Windows.

Kazer67 commented 4 months ago

Work great.

Seem like it should also be added to the "Add Manga" as I was able to add a new manga without End Date but I can't edit it now after adding it (I'm getting an Error 500):

Traceback (most recent call last):
  File "/home/dietpi/.local/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dietpi/.local/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dietpi/.local/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dietpi/.local/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dietpi/MyMangaDataBase-main/src/manga/routes.py", line 134, in edit_manga
    form.end_date.data = datetime.strptime(manga.end_date, "%Y-%m-%d").date()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: strptime() argument 1 must be str, not None
INFO:tdm:[2024-Jun-03 22:54] 192.168.1.10 GET http /manga/edit/12? 500 INTERNAL SERVER ERROR

After some digging, it apparently saved the END_DATE as NULL when adding a new manga without specifying an END DATE.

EdwinRodger commented 4 months ago

Fixed here 2837d3af253885d7d0ff5ab684582fa12a182fec

Apparently, in Linux, if date is set to 0001-01-01, it always returns as None, which got saved to end_date in your case. Whereas in windows, the date 0001-01-01 is always return as "0001-01-01".

Also if you want to delete the error entry, send a post request to following link - <domain name>/manga/delete/<id of the manga>

Kazer67 commented 4 months ago

Can confirm, it work now.

(I also fixed the issue directly in the SQLite database for the one who had NONE at END-DATE).