Corrections for simple booking app
Budget: $10 – $30 USD
This is the base code for a simple and classic booking app, with the obvious features, reservation, agenda, cancel reservation, profile section...
Consists of two users one only makes reservations and sees agenda, the second (is_instructor) can do this and also create and edit activities and schedules... you will have the whole picture by starting development.
Creating an activity is working, need to take a look if something is missing. Also schedule for activities.
Reservation is also working, need to make adjustments in some conditions.
Edit activity still needs some work, I’m getting this error “Reverse for 'edit' with no arguments not found. 1 pattern(s) tried: ['edit/(?P<post_id>[0-9]+)\\Z']”
Views are working, but there might be something wrong with users, I’m getting the message “UserProfile matching query does not exist” when I login with onother user, I might be using UserProfile when I should use User. If a user has no information in the UserProfile model seems to show the error.
On profile section you should be able to edit AbstractUser and UserProfile once the edit profile button is clicked by seeing a pre-populated form with the fields, then save changes.
When showing all activities, do not show activities that have started, only show the ones that can be reserved. That is if there's at least one minute left for the activity to start.
Inside the agenda view there is this condition, so only allow cancelation if there is still more than one hour before the scheduled time. Not working properly.
def see_agenda(request):
current_user = request.user
agendas = ActivityReservation.objects.filter(user=current_user)
message = None
if request.method == "POST":
action = request.POST.get('action', '')
schedule_id = request.POST.get('schedule_id')
if action == "cancel":
try:
schedule = ActivitySchedule.objects.get(pk=schedule_id)
now = timezone.now()
scheduled_datetime = datetime.combine(now.date(), schedule.date.timetz())
cancellation_time_limit = scheduled_datetime - timedelta(hours=1)
if now < cancellation_time_limit:
message = "You can only cancel reservations more than one hour before the scheduled time."
else:
reservation = ActivityReservation.objects.get(user=current_user, schedule=schedule)
reservation.delete()
message = "Reservation canceled successfully."
except ActivitySchedule.DoesNotExist:
raise Http404("Schedule not found.")
except ActivityReservation.DoesNotExist:
pass
return redirect('booking:agenda')
return render(request, 'booking/agenda.html', {'agendas': agendas, 'message': message})
This is just Django, no Javascript.
I'd like comments on code please.
I’ll share the code after a nice chat and having an agreed price.
Thanks for reading my requirements.
Consists of two users one only makes reservations and sees agenda, the second (is_instructor) can do this and also create and edit activities and schedules... you will have the whole picture by starting development.
Creating an activity is working, need to take a look if something is missing. Also schedule for activities.
Reservation is also working, need to make adjustments in some conditions.
Edit activity still needs some work, I’m getting this error “Reverse for 'edit' with no arguments not found. 1 pattern(s) tried: ['edit/(?P<post_id>[0-9]+)\\Z']”
Views are working, but there might be something wrong with users, I’m getting the message “UserProfile matching query does not exist” when I login with onother user, I might be using UserProfile when I should use User. If a user has no information in the UserProfile model seems to show the error.
On profile section you should be able to edit AbstractUser and UserProfile once the edit profile button is clicked by seeing a pre-populated form with the fields, then save changes.
When showing all activities, do not show activities that have started, only show the ones that can be reserved. That is if there's at least one minute left for the activity to start.
Inside the agenda view there is this condition, so only allow cancelation if there is still more than one hour before the scheduled time. Not working properly.
def see_agenda(request):
current_user = request.user
agendas = ActivityReservation.objects.filter(user=current_user)
message = None
if request.method == "POST":
action = request.POST.get('action', '')
schedule_id = request.POST.get('schedule_id')
if action == "cancel":
try:
schedule = ActivitySchedule.objects.get(pk=schedule_id)
now = timezone.now()
scheduled_datetime = datetime.combine(now.date(), schedule.date.timetz())
cancellation_time_limit = scheduled_datetime - timedelta(hours=1)
if now < cancellation_time_limit:
message = "You can only cancel reservations more than one hour before the scheduled time."
else:
reservation = ActivityReservation.objects.get(user=current_user, schedule=schedule)
reservation.delete()
message = "Reservation canceled successfully."
except ActivitySchedule.DoesNotExist:
raise Http404("Schedule not found.")
except ActivityReservation.DoesNotExist:
pass
return redirect('booking:agenda')
return render(request, 'booking/agenda.html', {'agendas': agendas, 'message': message})
This is just Django, no Javascript.
I'd like comments on code please.
I’ll share the code after a nice chat and having an agreed price.
Thanks for reading my requirements.