Skip to content

Commit 2e69902

Browse files
committed
stable
1 parent 78e7238 commit 2e69902

File tree

11 files changed

+25
-37
lines changed

11 files changed

+25
-37
lines changed

fastapi-postgres/common/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,9 @@ class Settings:
2929
JWT_EXP: int = 3600
3030
POSTGRES_DATABASE_URL: str = DATABASE_URL
3131

32+
# Field that defines the "owner" of the record in a multi-tenant setup
33+
# (e.g. teacher_id as the owner of students and their tasks)
34+
AUTH_PARENT_FIELD = "teacher_id"
35+
3236

3337
conf = Settings()

vue3/src/assets/layouts/full/FullLayout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const auth_store = useAuthStore();
2222
></v-progress-linear>
2323

2424
<v-container fluid class="page-wrapper">
25-
<RouterView />
25+
<RouterView />
2626
</v-container>
2727
</v-main>
2828
</v-app>

vue3/src/assets/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"toast.edit_success": "Successfully updated {model}",
44

55
"models.student": "Student",
6+
"models.teacher": "Teacher",
67
"models.assignment": "Assignment",
78

89
"name": "Name",

vue3/src/common/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const is_development: boolean = process.env.NODE_ENV === 'development';
99
const config: ConfigProps = {
1010
actTheme: 'DarkGreenTheme',
1111
fontTheme: 'Roboto',
12-
apiUrl: is_development ? 'http://0.0.0.0:5001' : import.meta.env.VITE_API_URL,
12+
apiUrl: is_development ? 'http://0.0.0.0:5001' : import.meta.env.VITE_API_URL
1313
};
1414

1515
export default config;

vue3/src/common/helper.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
export function array_obj_to_obj_with_key<T, K extends keyof T>(
2-
iterable: T[],
3-
value: T[K],
4-
key: K
5-
): T | undefined {
1+
export function array_obj_to_obj_with_key<T, K extends keyof T>(iterable: T[], value: T[K], key: K): T | undefined {
62
return iterable.find((o) => o[key] === value);
73
}
84

9-
export function array_to_dict<T, K extends keyof T & PropertyKey>(
10-
iterable: T[],
11-
key: K = 'id' as K
12-
): Record<T[K] & PropertyKey, T> {
13-
return Object.assign(
14-
{},
15-
...iterable.map((o) => ({ [o[key] as T[K] & PropertyKey]: o }))
16-
);
5+
export function array_to_dict<T, K extends keyof T & PropertyKey>(iterable: T[], key: K = 'id' as K): Record<T[K] & PropertyKey, T> {
6+
return Object.assign({}, ...iterable.map((o) => ({ [o[key] as T[K] & PropertyKey]: o })));
177
}
188

199
export function deep_copy_stringify<T>(obj: T): T {
2010
return JSON.parse(JSON.stringify(obj)) as T;
21-
}
11+
}

vue3/src/common/types/table.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export const get_columns_ag_by_model = (model: ModelType): ColDef[] => {
5151
export type EasyTableModelType = Teacher;
5252

5353
export const columns_teacher: Header[] = [
54-
{ value: 'id', sortable: true },
55-
{ value: 'phone', sortable: true }
54+
{ value: 'id', sortable: true },
55+
{ value: 'phone', sortable: true }
5656
] as Header[];
5757

5858
export const get_columns_easy_table_by_model = (title: ModelType): Header[] => {

vue3/src/views/components/form/Form.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ const url = computed<string>(() => route.params.url as string);
2020
const model = computed<ModelType>(() => route.params.model as ModelType);
2121
const isAdd: boolean = url.value === 'add';
2222
23-
2423
const obj = isAdd
2524
? {}
26-
: array_obj_to_obj_with_key<RowWithId, 'id'>(general_store.list[model.value] as RowWithId[], Number(url.value), 'id') ?? {};
25+
: (array_obj_to_obj_with_key<RowWithId, 'id'>(general_store.list[model.value] as RowWithId[], Number(url.value), 'id') ?? {});
2726
28-
const controls = computed<inputFilters>(() =>
29-
create_form_fields(get_form_by_model(model.value), obj)
30-
);
27+
const controls = computed<inputFilters>(() => create_form_fields(get_form_by_model(model.value), obj));
3128
const create_update = async (data: inputFilters) => {
3229
const message = t(isAdd ? 'toast.create_success' : 'toast.edit_success', {
3330
model: t(`models.${model.value}`)

vue3/src/views/components/general/StudentProfile.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ type StudentItem = {
1717
key: keyof Student;
1818
};
1919
20-
2120
const items: StudentItem[] = [
22-
{ icon: markRaw(PhoneIcon), key: 'phone' },
21+
{ icon: markRaw(PhoneIcon), key: 'phone' },
2322
{ icon: markRaw(SchoolIcon), key: 'grade' }
2423
];
2524
const delete_row = async () => {

vue3/src/views/components/table/ag_table/AGTableBase.vue

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { ref } from 'vue';
33
import { AgGridVue } from 'ag-grid-vue3';
4-
import type { ColDef, GridApi, GridOptions , GridReadyEvent} from 'ag-grid-community';
4+
import type { ColDef, GridApi, GridOptions, GridReadyEvent } from 'ag-grid-community';
55
66
import ActionRenderer from '@/views/components/table/ag_table/renderer/ActionRenderer.vue';
77
import AssignmentsRenderer from '@/views/components/table/ag_table/renderer/AssignmentsRenderer.vue';
@@ -19,9 +19,7 @@ const props = defineProps<Props>();
1919
const localizedCols: ColDef[] = props.columns.map((col: ColDef) => ({
2020
...col,
2121
headerName: t(`ag.headerName.${col.field as string}`),
22-
valueFormatter:
23-
col.valueFormatter ??
24-
((p) => (p.value && typeof p.value === 'object' ? '' : p.value)),
22+
valueFormatter: col.valueFormatter ?? ((p) => (p.value && typeof p.value === 'object' ? '' : p.value))
2523
}));
2624
2725
const gridApi = ref<GridApi | null>(null);
@@ -31,13 +29,13 @@ const gridOptions: GridOptions<AGTableModelType> = {
3129
animateRows: true,
3230
rowSelection: {
3331
mode: 'singleRow',
34-
enableClickSelection: false,
35-
},
32+
enableClickSelection: false
33+
}
3634
};
3735
3836
const gridComponents = {
3937
ActionRenderer,
40-
AssignmentsRenderer,
38+
AssignmentsRenderer
4139
};
4240
4341
const onGridReady = (params: GridReadyEvent) => {
@@ -54,8 +52,7 @@ const onFirstDataRendered = () => {
5452
const defaultColDef: ColDef = {
5553
resizable: true,
5654
sortable: true,
57-
filter: true,
58-
55+
filter: true
5956
};
6057
6158
const exportDataAsCsv = () => gridApi.value?.exportDataAsCsv();
@@ -83,4 +80,4 @@ defineExpose({ exportDataAsCsv });
8380
.ag-theme-alpine {
8481
--ag-input-icon-color: transparent;
8582
}
86-
</style>
83+
</style>

vue3/src/views/components/table/ag_table/AGTableHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { ref } from 'vue';
2+
import { ref } from 'vue';
33
import { ModelType } from '@/common/types';
44
55
interface Props {

0 commit comments

Comments
 (0)