Skip to content

Commit 321723a

Browse files
committed
Minor changes
When fullname not present, use username When admin is creating new appointment services adapt to the staff chosen Added funding file for sponsoring the project Added a fix for codecov Remove my personal info in setting
1 parent 209ebcd commit 321723a

File tree

13 files changed

+50
-15
lines changed

13 files changed

+50
-15
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: adamspd

.github/workflows/.coveragerc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[run]
2+
branch = True
3+
source = appointment
4+
5+
[report]
6+
exclude_lines =
7+
pragma: no cover
8+
def __str__
9+
if self.debug
10+
raise NotImplementedError
11+
if __name__ == .__main__.:
12+
13+
omit =
14+
*/tests/*
15+
manage.py

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
pip install coverage
3535
- name: Run Tests
3636
run: |
37-
coverage run --source=appointment manage.py test appointment.tests --parallel=10 --shuffle --verbosity=1
37+
coverage run --rcfile=.coveragerc manage.py test appointment.tests --parallel=10 --shuffle --verbosity=1
3838
coverage report
3939
coverage xml
4040
- name: Upload to Codecov

appointment/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ def get_staff_member_name(self):
214214
if hasattr(self.user, 'get_full_name') and callable(getattr(self.user, 'get_full_name')):
215215
name = self.user.get_full_name()
216216
else:
217-
name = self.user.first_name
217+
name = f"{self.user.first_name} {self.user.last_name}".strip()
218+
if not name:
219+
name = self.user.username
218220
return name
219221

220222
def get_staff_member_first_name(self):

appointment/static/js/app_admin/staff_index.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,9 @@ async function showCreateAppointmentModal(defaultStartTime, formattedDate) {
579579
let staffDropdown = null;
580580
if (isUserSuperUser) {
581581
staffDropdown = await populateStaffMembers(null, false);
582+
staffDropdown.id = "staffSelect";
583+
staffDropdown.disabled = false; // Enable dropdown
584+
attachEventListenersToDropdown(); // Attach event listener
582585
}
583586
servicesDropdown.id = "serviceSelect";
584587
servicesDropdown.disabled = false; // Enable dropdown
@@ -653,6 +656,7 @@ async function showEventModal(eventId = null, isEditMode, isCreatingMode = false
653656
let staffDropdown = null;
654657
if (isUserSuperUser) {
655658
staffDropdown = await getStaffDropdown(appointment.staff_id, isEditMode);
659+
attachEventListenersToDropdown(); // Attach event listener
656660
}
657661

658662
document.getElementById('eventModalBody').innerHTML = generateModalContent(appointment, servicesDropdown, isEditMode, staffDropdown);
@@ -758,14 +762,26 @@ async function submitChanges() {
758762
function collectFormDataFromModal(modal) {
759763
const inputs = modal.querySelectorAll("input");
760764
const serviceId = modal.querySelector("#serviceSelect").value;
761-
const staffId = modal.querySelector("#staffSelect").value;
765+
let staffId = null;
766+
767+
if (isUserSuperUser) {
768+
// If the user is a superuser, get the staff ID from the dropdown
769+
const staffDropdown = modal.querySelector("#staffSelect");
770+
if (staffDropdown) {
771+
staffId = staffDropdown.value;
772+
}
773+
}
774+
762775
const data = {
763776
isCreating: AppState.isCreating,
764777
service_id: serviceId,
765-
staff_id: staffId,
766778
appointment_id: AppState.eventIdSelected
767779
};
768780

781+
if (staffId) {
782+
data.staff_id = staffId;
783+
}
784+
769785
inputs.forEach(input => {
770786
if (input.name !== "date") {
771787
let key = input.name.replace(/([A-Z])/g, '_$1').toLowerCase();

appointment/static/js/appointments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function fetchNonWorkingDays(staffId, callback) {
158158
return; // Exit the function early
159159
}
160160
let ajaxData = {
161-
'staff_member': staffId,
161+
'staff_id': staffId,
162162
};
163163

164164
$.ajax({

appointment/templates/administration/staff_index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@
344344
function createCommonInputFields(appointment, servicesDropdown, isEditMode, defaultStartTime, staffDropdown) {
345345
const startTimeValue = isEditMode ? moment(appointment.start_time).format('HH:mm:ss') : defaultStartTime;
346346
const disabledAttribute = isEditMode ? '' : 'disabled';
347-
347+
348348
let superuserInputField = '';
349349
if (isUserSuperUser) {
350350
superuserInputField = `

appointment/templates/administration/staff_list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ <h2 class="section-header-itm">{% trans 'Staff Members' %}</h2>
4343
<tbody>
4444
{% for staff_member in staff_members %}
4545
<tr>
46-
<td>{{ staff_member.user.first_name }} {{ staff_member.user.last_name }}</td>
47-
<td>{{ staff_member.user.email }}</td>
46+
<td>{{ staff_member.get_staff_member_name }}</td>
47+
<td>{{ staff_member.user.email|default:"N/A" }}</td>
4848
<td>
4949
<a href="{% url 'appointment:user_profile' staff_member.user.id %}"
5050
class="modify-btn button-color-blue">{% trans 'View Profile' %}</a>

appointment/templates/administration/user_profile.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
<h2>{% trans 'Personal Information' %}</h2>
3636
<!-- Display fields from PersonalInformationForm -->
3737
<div class="section-content">
38-
<p><strong>{% trans 'First name' %}:</strong> {{ user.first_name }}</p>
39-
<p><strong>{% trans 'Last name' %}:</strong> {{ user.last_name }}</p>
40-
<p><strong>{% trans 'Email' %}:</strong> {{ user.email }}</p>
38+
<p><strong>{% trans 'First name' %}:</strong> {{ user.first_name|default:user.username }}</p>
39+
<p><strong>{% trans 'Last name' %}:</strong> {{ user.last_name|default:"N/A" }}</p>
40+
<p><strong>{% trans 'Email' %}:</strong> {{ user.email|default:"N/A" }}</p>
4141
</div>
4242
<a href="{% url 'appointment:update_user_info' user.id %}"
4343
class="section-content-button modify-btn button-color-blue">
@@ -242,7 +242,7 @@ <h2>{% trans 'Service Offered' %}</h2>
242242
{% for service in services_offered %}
243243
<tr>
244244
<td>{{ service.name }}</td>
245-
<td>{{ service.description }}</td>
245+
<td>{{ service.description|default:"N/A" }}</td>
246246
<td>{{ service.get_duration }}</td>
247247
<td>{{ service.get_price_text }}</td>
248248
<td>{{ service.get_down_payment_text }}</td>

appointment/templates/email_sender/admin_new_appointment_email.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h1>{% translate 'New Appointment Request' %}</h1>
6060
<p><strong>{% translate 'Appointment Date' %}:</strong> {{ appointment.appointment_request.date }}</p>
6161
<p><strong>{% translate 'Time' %}:</strong> {{ appointment.appointment_request.start_time }}
6262
- {{ appointment.appointment_request.end_time }}</p>
63-
<p><strong>{% translate 'Contact Details' %}:</strong> {{ appointment.phone }} | {{ client_email }}</p>
63+
<p><strong>{% translate 'Contact Details' %}:</strong> {{ appointment.phone }} | {{ appointment.client.email }}</p>
6464
<p><strong>{% translate 'Additional Info' %}:</strong> {{ appointment.additional_info|default:"N/A" }}</p>
6565
</div>
6666

0 commit comments

Comments
 (0)