-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: academic calendar controllers and routes #81
Open
mateusz-plaska
wants to merge
12
commits into
main
Choose a base branch
from
feat/academic-calendar-controllers-and-routes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
69a23e0
feat: update academic_calendar, holiday and day_swap model
mateusz-plaska b08d78a
feat: add controllers for academic_calendar, holiday and day_swap
mateusz-plaska 8ef330e
feat: add routes for academic_calendar, holiday and day_swap
mateusz-plaska 55801c4
feat: add db seeder for academic_calendar, holiday and day_swap
mateusz-plaska 2213c2f
refactor: rename academic_calendar seeder name
mateusz-plaska 47e22eb
refactor: convert route URLs to snake_case
mateusz-plaska a3bc514
fix: fix migrations types
mateusz-plaska 7947aea
fix: fix models types and column_names
mateusz-plaska 4da9513
feat: update seeder to libraries and other relations
mateusz-plaska baae2bc
feat: add library controllers and update others
mateusz-plaska 856c646
feat: add routes for library controller
mateusz-plaska ce1571d
fix: fix operator=
mateusz-plaska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { HttpContext } from "@adonisjs/core/http"; | ||
|
||
import AcademicCalendar from "#models/academic_calendar"; | ||
import { paginationValidator } from "#validators/pagination"; | ||
import { showValidator } from "#validators/show"; | ||
|
||
export default class AcademicCalendarsController { | ||
protected readonly relations = ["holidays", "daySwaps"]; | ||
|
||
/** | ||
* Display a list of resource | ||
*/ | ||
async index({ request }: HttpContext) { | ||
const { page, limit } = await request.validateUsing(paginationValidator); | ||
const baseQuery = AcademicCalendar.query().withScopes((scopes) => { | ||
scopes.handleSearchQuery(request.qs()); | ||
scopes.preloadRelations(request.only(this.relations)); | ||
scopes.handleSortQuery(request.input("sort")); | ||
}); | ||
let academicCalendars; | ||
if (page !== undefined) { | ||
academicCalendars = await baseQuery.paginate(page, limit ?? 10); | ||
} else { | ||
academicCalendars = { data: await baseQuery }; | ||
} | ||
return academicCalendars; | ||
} | ||
|
||
/** | ||
* Show individual record | ||
*/ | ||
async show({ request }: HttpContext) { | ||
const { | ||
params: { id }, | ||
} = await request.validateUsing(showValidator); | ||
const academicCalendar = await AcademicCalendar.query() | ||
.withScopes((scopes) => { | ||
scopes.preloadRelations(request.only(this.relations)); | ||
}) | ||
.where("id", id) | ||
.firstOrFail(); | ||
|
||
return { data: academicCalendar }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { HttpContext } from "@adonisjs/core/http"; | ||
|
||
import DaySwap from "#models/day_swap"; | ||
import { paginationValidator } from "#validators/pagination"; | ||
import { showValidator } from "#validators/show"; | ||
|
||
export default class DaySwapsController { | ||
protected readonly relations = ["academicCalendar"]; | ||
|
||
/** | ||
* Display a list of resource | ||
*/ | ||
async index({ request }: HttpContext) { | ||
const { page, limit } = await request.validateUsing(paginationValidator); | ||
const baseQuery = DaySwap.query().withScopes((scopes) => { | ||
scopes.handleSearchQuery(request.qs(), "changedWeekday"); | ||
scopes.preloadRelations(request.only(this.relations)); | ||
scopes.handleSortQuery(request.input("sort")); | ||
}); | ||
let daySwaps; | ||
if (page !== undefined) { | ||
daySwaps = await baseQuery.paginate(page, limit ?? 10); | ||
} else { | ||
daySwaps = { data: await baseQuery }; | ||
} | ||
return daySwaps; | ||
} | ||
|
||
/** | ||
* Show individual record | ||
*/ | ||
async show({ request }: HttpContext) { | ||
const { | ||
params: { id }, | ||
} = await request.validateUsing(showValidator); | ||
const academicCalendar = await DaySwap.query() | ||
.withScopes((scopes) => { | ||
scopes.preloadRelations(request.only(this.relations)); | ||
}) | ||
.where("id", id) | ||
.firstOrFail(); | ||
|
||
return { data: academicCalendar }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { HttpContext } from "@adonisjs/core/http"; | ||
|
||
import Holiday from "#models/holiday"; | ||
import { paginationValidator } from "#validators/pagination"; | ||
import { showValidator } from "#validators/show"; | ||
|
||
export default class HolidaysController { | ||
protected readonly relations = ["academicCalendar"]; | ||
|
||
/** | ||
* Display a list of resource | ||
*/ | ||
async index({ request }: HttpContext) { | ||
const { page, limit } = await request.validateUsing(paginationValidator); | ||
const baseQuery = Holiday.query().withScopes((scopes) => { | ||
scopes.handleSearchQuery(request.qs()); | ||
scopes.preloadRelations(request.only(this.relations)); | ||
scopes.handleSortQuery(request.input("sort")); | ||
}); | ||
let holidays; | ||
if (page !== undefined) { | ||
holidays = await baseQuery.paginate(page, limit ?? 10); | ||
} else { | ||
holidays = { data: await baseQuery }; | ||
} | ||
return holidays; | ||
} | ||
|
||
/** | ||
* Show individual record | ||
*/ | ||
async show({ request }: HttpContext) { | ||
const { | ||
params: { id }, | ||
} = await request.validateUsing(showValidator); | ||
const academicCalendar = await Holiday.query() | ||
.withScopes((scopes) => { | ||
scopes.preloadRelations(request.only(this.relations)); | ||
}) | ||
.where("id", id) | ||
.firstOrFail(); | ||
|
||
return { data: academicCalendar }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { HttpContext } from "@adonisjs/core/http"; | ||
|
||
import Library from "#models/library"; | ||
import { paginationValidator } from "#validators/pagination"; | ||
import { showValidator } from "#validators/show"; | ||
|
||
export default class LibrariesController { | ||
protected readonly relations = ["regularHours", "specialHours", "building"]; | ||
|
||
/** | ||
* Display a list of resource | ||
*/ | ||
async index({ request }: HttpContext) { | ||
const { page, limit } = await request.validateUsing(paginationValidator); | ||
const baseQuery = Library.query().withScopes((scopes) => { | ||
scopes.handleSearchQuery(request.qs()); | ||
scopes.preloadRelations(request.only(this.relations)); | ||
scopes.handleSortQuery(request.input("sort")); | ||
}); | ||
let libraries; | ||
if (page !== undefined) { | ||
libraries = await baseQuery.paginate(page, limit ?? 10); | ||
} else { | ||
libraries = { data: await baseQuery }; | ||
} | ||
return libraries; | ||
} | ||
|
||
/** | ||
* Show individual record | ||
*/ | ||
async show({ request }: HttpContext) { | ||
const { | ||
params: { id }, | ||
} = await request.validateUsing(showValidator); | ||
const library = await Library.query() | ||
.withScopes((scopes) => { | ||
scopes.preloadRelations(request.only(this.relations)); | ||
}) | ||
.where("id", id) | ||
.firstOrFail(); | ||
|
||
return { data: library }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could also add
buildings.libraries.{regular,special}Hours