Skip to content

Commit

Permalink
Add "cancelled" field to LeaveAdmin list_editable and sort user by us…
Browse files Browse the repository at this point in the history
…ername
  • Loading branch information
Tubo committed Jan 17, 2024
1 parent d521189 commit e4d112c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion radscheduler/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,11 @@ class LeaveAdmin(admin.ModelAdmin):
"microster",
"printed",
"no_abutting_weekend",
"cancelled",
"created",
"last_edited",
)
list_editable = ("dot_approved", "reg_approved", "printed", "microster", "no_abutting_weekend")
list_editable = ("dot_approved", "reg_approved", "printed", "microster", "no_abutting_weekend", "cancelled")
list_filter = (
(
"date",
Expand Down
2 changes: 1 addition & 1 deletion radscheduler/core/ical.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LeaveFeed(ICalFeed):
timezone = "Pacific/Auckland"

def items(self):
return Leave.objects.filter(date__gte=date.today() - timedelta(days=365)).select_related(
return Leave.objects.filter(date__gte=date.today() - timedelta(days=365), cancelled=False).select_related(
"registrar", "registrar__user"
)

Expand Down
2 changes: 1 addition & 1 deletion radscheduler/core/views/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_calendar(request):
shifts = Shift.objects.filter(date__gte=start, date__lte=end, registrar__isnull=False).select_related(
"registrar", "registrar__user"
)
leaves = Leave.objects.filter(date__gte=start, date__lte=end).select_related(
leaves = Leave.objects.filter(date__gte=start, date__lte=end, cancelled=False).select_related(
"registrar", "registrar__user"
)
events = shifts_to_events(shifts) + leaves_to_events(leaves) + holidays_to_events(start.year)
Expand Down
1 change: 0 additions & 1 deletion radscheduler/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class UserAdmin(auth_admin.UserAdmin):
list_editable = ["name"]
search_fields = ["name", "username"]
inlines = [RegistrarInline]
ordering = ["-registrar__start"]
list_select_related = ["registrar"]

def registrar_year(self, obj: User) -> Any:
Expand Down
16 changes: 16 additions & 0 deletions radscheduler/users/migrations/0004_alter_user_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.6 on 2024-01-17 12:34

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("users", "0003_user_phone"),
]

operations = [
migrations.AlterModelOptions(
name="user",
options={"ordering": ["username"]},
),
]
3 changes: 3 additions & 0 deletions radscheduler/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class User(AbstractUser):
employee_number = CharField(max_length=20, blank=True, null=True)
phone = CharField(max_length=20, blank=True, null=True)

class Meta:
ordering = ["username"]

def get_absolute_url(self) -> str:
"""Get URL for user's detail view.
Expand Down

0 comments on commit e4d112c

Please sign in to comment.