Skip to content

Commit 61d298f

Browse files
authored
updated documentation and models (#64)
* updated documentation and models * Added tests for newly added line
1 parent c5c6553 commit 61d298f

File tree

5 files changed

+107
-4
lines changed

5 files changed

+107
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ users to define custom configurations for time slots, lead time, and finish time
2121
provided. This app proficiently manages conflicts and availability for appointments, ensuring a seamless user
2222
experience.
2323

24+
For a detailed walkthrough and live example of the system, please refer to
25+
[this tutorial](https://github.com/adamspd/django-appointment/tree/main/docs/explanation.md).
26+
2427
Detailed documentation can be found in
2528
the [docs' directory](https://github.com/adamspd/django-appointment/tree/main/docs/README.md).
2629
For changes and migration information, please refer to the [release

appointment/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class AppointmentRequest(models.Model):
284284
start_time = models.TimeField()
285285
end_time = models.TimeField()
286286
service = models.ForeignKey(Service, on_delete=models.CASCADE)
287-
staff_member = models.ForeignKey(StaffMember, on_delete=models.DO_NOTHING)
287+
staff_member = models.ForeignKey(StaffMember, on_delete=models.SET_NULL, null=True)
288288
payment_type = models.CharField(max_length=4, choices=PAYMENT_TYPES, default='full')
289289
id_request = models.CharField(max_length=100, blank=True, null=True)
290290

@@ -368,7 +368,7 @@ class Appointment(models.Model):
368368
Version: 1.1.0
369369
Since: 1.0.0
370370
"""
371-
client = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
371+
client = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True)
372372
appointment_request = models.OneToOneField(AppointmentRequest, on_delete=models.CASCADE)
373373
phone = PhoneNumberField(blank=True)
374374
address = models.CharField(max_length=255, blank=True, null=True, default="",
@@ -430,6 +430,8 @@ def get_service_duration(self):
430430
return self.appointment_request.service.get_duration()
431431

432432
def get_staff_member_name(self):
433+
if not self.appointment_request.staff_member:
434+
return ""
433435
return self.appointment_request.staff_member.get_staff_member_name()
434436

435437
def get_staff_member(self):

appointment/templates/administration/manage_service.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ <h2>{{ page_title }}</h2>
1515
<form method="post" enctype="multipart/form-data">
1616
{% csrf_token %}
1717
{{ form.as_p }}
18-
{% if btn_txt %}
18+
{% if btn_text %}
1919
<button type="submit" class="btn btn-primary">{{ btn_text }}</button>
2020
{% else %}
21-
{% if request.user.is_superuser %}
21+
{% if request.user.is_superuser and service.id %}
2222
<div class="service-btn-container">
2323
<a href="{% url 'appointment:update_service' service_id=service.id %}"
2424
class="modify-btn button-color-blue service-btn">

appointment/tests/models/test_model_appointment.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,15 @@ def test_appt_to_dict(self):
208208
actual_response = self.appointment.to_dict()
209209
actual_response.pop('id_request', None)
210210
self.assertEqual(actual_response, response)
211+
212+
def test_get_staff_member_name_with_staff_member(self):
213+
"""Test if you get_staff_member_name method returns the correct name when a staff member is associated."""
214+
expected_name = self.staff_member1.get_staff_member_name()
215+
actual_name = self.appointment.get_staff_member_name()
216+
self.assertEqual(actual_name, expected_name)
217+
218+
def test_get_staff_member_name_without_staff_member(self):
219+
"""Test if you get_staff_member_name method returns an empty string when no staff member is associated."""
220+
self.appointment.appointment_request.staff_member = None
221+
self.appointment.appointment_request.save()
222+
self.assertEqual(self.appointment.get_staff_member_name(), "")

docs/explanation.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Django Appointment System: Screenshots and Tutorial
2+
3+
Welcome to the Django Appointment System! This guide will walk you through setting up and using the system, complete with screenshots and a video tutorial.
4+
5+
## Getting Started
6+
7+
After completing the initial setup steps - making migrations, migrating, running the server, and creating a superuser - you might want to create an appointment as a client. However, this is not possible initially as no services or staff members are yet configured.
8+
9+
### Adding a Service
10+
11+
Your first step is to add a service. Navigate to the admin page and add a service at:
12+
https://mysuperwebsite.com/app-admin/add-service/
13+
14+
![Creating Service](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/creating_service.png?raw=true)
15+
16+
### Attempting to Create an Appointment
17+
18+
If you attempt to create an appointment request now, it's still not possible as there are no staff members yet:
19+
20+
![Appointment Request without Staff Member](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/appointment_request_w_sm.png?raw=true)
21+
22+
Similarly, if you check the list of appointments, it will be empty and you'll get a warning:
23+
24+
![Appointment List without Staff Member](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/appointment_list_admin.png?raw=true)
25+
26+
### Adding a Staff Member
27+
28+
To add a staff member, visit:
29+
30+
![Staff Member List](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/staff_member_list.png?raw=true)
31+
32+
You can either add a new staff member or assign yourself as a staff member, especially if you are a superuser. In this example, I will demonstrate using the `Staff me` button.
33+
34+
### Updating Your Profile
35+
36+
Once you have created a staff member profile, you need to specify the services you offer. After doing so, your initial profile page will look something like this:
37+
38+
![Initial Profile](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/initial_profile.png?raw=true)
39+
40+
To edit your appointment information, such as the services you offer, click on the edit icon next to `Appointment Information`:
41+
42+
![Profile Edit](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/adding_service_to_profile.png?raw=true)
43+
44+
After selecting the services you offer, you may leave other fields blank if desired, and then click `Save`.
45+
46+
Additionally, select the days you wish to work by clicking the `add icon` next to `Working Hours`. For demonstration purposes, I have chosen Saturdays and Sundays from 9 AM to 5 PM.
47+
48+
Your updated profile should look like this:
49+
50+
![Profile after Editing](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/profile_after_editing.png?raw=true)
51+
52+
### Client's Perspective: Creating Appointments
53+
54+
Now, users can start creating appointments. The interface for clients would appear as follows:
55+
56+
![Appointment Request with Staff Member](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/before_creating_appt_request.png?raw=true)
57+
58+
Notice that only Saturdays and Sundays are selectable, with the only staff member (you) selected by default.
59+
60+
Let's create an appointment request for Saturday, January 13th, 2024, at 3:00 PM:
61+
62+
![Creating Appointment Request](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/creating_appt_request.png?raw=true)
63+
64+
Next, add your personal information:
65+
66+
![Adding Personal Information](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/adding_client_information.png?raw=true)
67+
68+
### Payment Options
69+
70+
If the service is paid and a payment link is set in settings, the `Pay now` button will appear. If down payments are accepted, a `Down Payment` button will also be available. Otherwise, a `Finish` button will be displayed.
71+
72+
Upon completion, an account is created for the user, and an email is sent with appointment and account details, provided the email settings are correctly configured.
73+
74+
### Managing Appointments
75+
76+
As an admin, you can now view the newly created appointment in your staff member appointment list:
77+
78+
![Admin Appointments](https://github.com/adamspd/django-appointment/blob/main/docs/screenshots/admin_appointments.png?raw=true)
79+
80+
In the admin interface, you have various options to manage appointments, such as editing, adding new appointments, deleting, or rescheduling them by dragging and dropping.
81+
82+
### Video Tutorial
83+
84+
For a more comprehensive guide, including visual demonstrations of these steps, please watch the following video tutorial:
85+
86+
[Link to Video Tutorial]

0 commit comments

Comments
 (0)