mirror of
https://github.com/ae-utbm/sith.git
synced 2026-03-14 15:45:02 +00:00
Compare commits
2 Commits
show-my-st
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
173311c1d5 | ||
|
|
2995823d6e |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -24,9 +24,6 @@ node_modules/
|
|||||||
# compiled documentation
|
# compiled documentation
|
||||||
site/
|
site/
|
||||||
|
|
||||||
# rollup-bundle-visualizer report
|
|
||||||
.bundle-size-report.html
|
|
||||||
|
|
||||||
### Redis ###
|
### Redis ###
|
||||||
|
|
||||||
# Ignore redis binary dump (dump.rdb) files
|
# Ignore redis binary dump (dump.rdb) files
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"ignoreUnknown": false,
|
"ignoreUnknown": false,
|
||||||
"includes": ["**/static/**", "vite.config.mts"]
|
"includes": ["**/static/**"]
|
||||||
},
|
},
|
||||||
"formatter": {
|
"formatter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export class NfcInput extends inheritHtmlElement("input") {
|
|||||||
window.alert(gettext("Unsupported NFC card"));
|
window.alert(gettext("Unsupported NFC card"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// biome-ignore lint/correctness/noUndeclaredVariables: browser API
|
||||||
ndef.addEventListener("reading", (event: NDEFReadingEvent) => {
|
ndef.addEventListener("reading", (event: NDEFReadingEvent) => {
|
||||||
this.removeAttribute("scan");
|
this.removeAttribute("scan");
|
||||||
this.node.value = event.serialNumber.replace(/:/g, "").toUpperCase();
|
this.node.value = event.serialNumber.replace(/:/g, "").toUpperCase();
|
||||||
|
|||||||
@@ -248,15 +248,14 @@ class UserTabsMixin(TabedViewMixin):
|
|||||||
"name": _("Groups"),
|
"name": _("Groups"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
can_view_account = (
|
if (
|
||||||
hasattr(user, "customer")
|
hasattr(user, "customer")
|
||||||
and user.customer
|
and user.customer
|
||||||
and (
|
and (
|
||||||
user == self.request.user
|
user == self.request.user
|
||||||
or self.request.user.has_perm("counter.view_customer")
|
or self.request.user.has_perm("counter.view_customer")
|
||||||
)
|
)
|
||||||
)
|
):
|
||||||
if can_view_account or user.preferences.show_my_stats:
|
|
||||||
tab_list.append(
|
tab_list.append(
|
||||||
{
|
{
|
||||||
"url": reverse("core:user_stats", kwargs={"user_id": user.id}),
|
"url": reverse("core:user_stats", kwargs={"user_id": user.id}),
|
||||||
@@ -264,7 +263,6 @@ class UserTabsMixin(TabedViewMixin):
|
|||||||
"name": _("Stats"),
|
"name": _("Stats"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if can_view_account:
|
|
||||||
tab_list.append(
|
tab_list.append(
|
||||||
{
|
{
|
||||||
"url": reverse("core:user_account", kwargs={"user_id": user.id}),
|
"url": reverse("core:user_account", kwargs={"user_id": user.id}),
|
||||||
@@ -351,7 +349,7 @@ class UserGodfathersTreeView(UserTabsMixin, CanViewMixin, DetailView):
|
|||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
class UserStatsView(UserTabsMixin, UserPassesTestMixin, DetailView):
|
class UserStatsView(UserTabsMixin, CanViewMixin, DetailView):
|
||||||
"""Display a user's stats."""
|
"""Display a user's stats."""
|
||||||
|
|
||||||
model = User
|
model = User
|
||||||
@@ -359,20 +357,15 @@ class UserStatsView(UserTabsMixin, UserPassesTestMixin, DetailView):
|
|||||||
context_object_name = "profile"
|
context_object_name = "profile"
|
||||||
template_name = "core/user_stats.jinja"
|
template_name = "core/user_stats.jinja"
|
||||||
current_tab = "stats"
|
current_tab = "stats"
|
||||||
queryset = User.objects.exclude(customer=None).select_related(
|
queryset = User.objects.exclude(customer=None).select_related("customer")
|
||||||
"customer", "_preferences"
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_func(self):
|
def dispatch(self, request, *arg, **kwargs):
|
||||||
profile: User = self.get_object()
|
profile = self.get_object()
|
||||||
return (
|
if not (
|
||||||
profile == self.request.user
|
profile == request.user or request.user.has_perm("counter.view_customer")
|
||||||
or self.request.user.has_perm("counter.view_customer")
|
):
|
||||||
or (
|
raise PermissionDenied
|
||||||
self.request.user.can_view(profile)
|
return super().dispatch(request, *arg, **kwargs)
|
||||||
and profile.preferences.show_my_stats
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs = super().get_context_data(**kwargs)
|
kwargs = super().get_context_data(**kwargs)
|
||||||
|
|||||||
2047
package-lock.json
generated
2047
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,8 @@
|
|||||||
"compile-dev": "vite build --mode development",
|
"compile-dev": "vite build --mode development",
|
||||||
"serve": "vite build --mode development --watch --minify false",
|
"serve": "vite build --mode development --watch --minify false",
|
||||||
"openapi": "openapi-ts",
|
"openapi": "openapi-ts",
|
||||||
|
"analyse-dev": "vite-bundle-visualizer --mode development",
|
||||||
|
"analyse-prod": "vite-bundle-visualizer --mode production",
|
||||||
"check": "tsc && biome check --write"
|
"check": "tsc && biome check --write"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
@@ -33,9 +35,10 @@
|
|||||||
"@types/cytoscape-cxtmenu": "^3.4.5",
|
"@types/cytoscape-cxtmenu": "^3.4.5",
|
||||||
"@types/cytoscape-klay": "^3.1.5",
|
"@types/cytoscape-klay": "^3.1.5",
|
||||||
"@types/js-cookie": "^3.0.6",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"rollup-plugin-visualizer": "^7.0.1",
|
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vite": "^8.0.0"
|
"vite": "^7.3.1",
|
||||||
|
"vite-bundle-visualizer": "^1.2.1",
|
||||||
|
"vite-plugin-static-copy": "^3.2.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alpinejs/sort": "^3.15.8",
|
"@alpinejs/sort": "^3.15.8",
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
|
// biome-ignore lint/correctness/noNodejsModules: this is backend side
|
||||||
import { parse, resolve } from "node:path";
|
import { parse, resolve } from "node:path";
|
||||||
import inject from "@rollup/plugin-inject";
|
import inject from "@rollup/plugin-inject";
|
||||||
import { glob } from "glob";
|
import { glob } from "glob";
|
||||||
import { visualizer } from "rollup-plugin-visualizer";
|
import type { Rollup } from "vite";
|
||||||
import {
|
import { type AliasOptions, defineConfig, type UserConfig } from "vite";
|
||||||
type AliasOptions,
|
|
||||||
defineConfig,
|
|
||||||
type PluginOption,
|
|
||||||
type Rollup,
|
|
||||||
type UserConfig,
|
|
||||||
} from "vite";
|
|
||||||
import tsconfig from "./tsconfig.json";
|
import tsconfig from "./tsconfig.json";
|
||||||
|
|
||||||
const outDir = resolve(__dirname, "./staticfiles/generated/bundled");
|
const outDir = resolve(__dirname, "./staticfiles/generated/bundled");
|
||||||
|
const vendored = resolve(outDir, "vendored");
|
||||||
|
const nodeModules = resolve(__dirname, "node_modules");
|
||||||
const collectedFiles = glob.sync(
|
const collectedFiles = glob.sync(
|
||||||
"./!(static)/static/bundled/**/*?(-)index.?(m)[j|t]s?(x)",
|
"./!(static)/static/bundled/**/*?(-)index.?(m)[j|t]s?(x)",
|
||||||
);
|
);
|
||||||
@@ -45,6 +42,7 @@ function getRelativeAssetPath(path: string): string {
|
|||||||
return relativePath.join("/");
|
return relativePath.join("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// biome-ignore lint/style/noDefaultExport: this is recommended by documentation
|
||||||
export default defineConfig((config: UserConfig) => {
|
export default defineConfig((config: UserConfig) => {
|
||||||
return {
|
return {
|
||||||
base: "/static/bundled/",
|
base: "/static/bundled/",
|
||||||
@@ -88,7 +86,6 @@ export default defineConfig((config: UserConfig) => {
|
|||||||
Alpine: "alpinejs",
|
Alpine: "alpinejs",
|
||||||
htmx: "htmx.org",
|
htmx: "htmx.org",
|
||||||
}),
|
}),
|
||||||
visualizer({ filename: ".bundle-size-report.html" }) as PluginOption,
|
|
||||||
],
|
],
|
||||||
} satisfies UserConfig;
|
} satisfies UserConfig;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user