mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 04:49:37 +02:00
feat: Update Visit model to use DateTimeField for start and end dates, and enhance AdventureModal with datetime-local inputs
This commit is contained in:
parent
6f720a154f
commit
9fd2a142cb
6 changed files with 152 additions and 35 deletions
|
@ -136,9 +136,11 @@ class AdventureSerializer(CustomModelSerializer):
|
|||
def get_is_visited(self, obj):
|
||||
current_date = timezone.now().date()
|
||||
for visit in obj.visits.all():
|
||||
if visit.start_date and visit.end_date and (visit.start_date <= current_date):
|
||||
start_date = visit.start_date.date() if isinstance(visit.start_date, timezone.datetime) else visit.start_date
|
||||
end_date = visit.end_date.date() if isinstance(visit.end_date, timezone.datetime) else visit.end_date
|
||||
if start_date and end_date and (start_date <= current_date):
|
||||
return True
|
||||
elif visit.start_date and not visit.end_date and (visit.start_date <= current_date):
|
||||
elif start_date and not end_date and (start_date <= current_date):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue