Skip to content

Commit

Permalink
improved startpage
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Jan 3, 2025
1 parent 9eca467 commit dc58b42
Show file tree
Hide file tree
Showing 41 changed files with 118 additions and 7 deletions.
9 changes: 7 additions & 2 deletions cookbook/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def get_user_label(self, obj):
class Meta:
list_serializer_class = SpaceFilterSerializer
model = User
fields = ('id', 'username', 'first_name', 'last_name', 'display_name')
fields = ('id', 'username', 'first_name', 'last_name', 'display_name', 'is_staff', 'is_superuser', 'is_active')
read_only_fields = ('username',)


Expand Down Expand Up @@ -1294,7 +1294,12 @@ class ViewLogSerializer(serializers.ModelSerializer):
def create(self, validated_data):
validated_data['created_by'] = self.context['request'].user
validated_data['space'] = self.context['request'].space
return super().create(validated_data)

view_log = ViewLog.objects.filter(recipe=validated_data['recipe'], created_by=self.context['request'].user, created_at__gt=(timezone.now() - timezone.timedelta(minutes=5)), space=self.context['request'].space).first()
if not view_log:
view_log = ViewLog.objects.create(recipe=validated_data['recipe'], created_by=self.context['request'].user, space=self.context['request'].space)

return view_log

class Meta:
model = ViewLog
Expand Down
2 changes: 2 additions & 0 deletions cookbook/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,8 @@ def get_paginated_response(self, data):
description=_('Returns the results in randomized order. [''true''/''<b>false</b>'']')),
OpenApiParameter(name='new',
description=_('Returns new results first in search results. [''true''/''<b>false</b>'']')),
OpenApiParameter(name='num_recent', description=_(
'Returns the given number of recently viewed recipes before search results (if given)'), type=int),
OpenApiParameter(name='timescooked', description=_(
'Filter recipes cooked X times or more. Negative values returns cooked less than X times'), type=int),
OpenApiParameter(
Expand Down
6 changes: 6 additions & 0 deletions vue3/src/apps/tandoor/Tandoor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
{{ $t('Messages') }}
<message-list-dialog></message-list-dialog>
</v-list-item>
<v-list-item :href="getDjangoUrl('admin')" target="_blank" v-if="useUserPreferenceStore().userSettings.user.isSuperuser">
<template #prepend>
<v-icon icon="fa-solid fa-shield"></v-icon>
</template>
{{ $t('Admin') }}
</v-list-item>
<v-list-item :href="getDjangoUrl('accounts/logout')" link>
<template #prepend>
<v-icon icon="fa-solid fa-arrow-right-from-bracket"></v-icon>
Expand Down
11 changes: 9 additions & 2 deletions vue3/src/components/display/HorizontalRecipeWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {DisplayBreakpoint, useDisplay} from "vuetify";
import {ApiApi, ApiRecipeListRequest, Keyword, Recipe, RecipeOverview} from "@/openapi";
import {homePageCols} from "@/utils/breakpoint_utils";
import {useI18n} from "vue-i18n";
import {DateTime} from "luxon";
//TODO mode ideas "last year/month/cooked long ago"
const props = defineProps(
Expand Down Expand Up @@ -116,7 +117,7 @@ function loadRecipes() {
switch (props.mode) {
case 'recent':
// TODO implement correct parameter
requestParameters._new = 'true'
requestParameters.numRecent = 16
break;
case 'new':
requestParameters._new = 'true'
Expand Down Expand Up @@ -147,7 +148,13 @@ function doRecipeRequest(params: ApiRecipeListRequest) {
let api = new ApiApi()
api.apiRecipeList(params).then((r) => {
recipes.value = r.results
if (props.mode == 'new') {
recipes.value = r.results.filter(r => r._new)
} else if (props.mode == 'recent') {
recipes.value = r.results.filter(r => r.recent != "0")
} else {
recipes.value = r.results
}
}).finally(() => {
loading.value = false
})
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"Added_To_Shopping_List": "",
"Added_by": "",
"Added_on": "",
"Admin": "",
"Advanced": "",
"App": "",
"Are_You_Sure": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"Added_To_Shopping_List": "Добавено към списъка за пазаруване",
"Added_by": "Добавено от",
"Added_on": "Добавено",
"Admin": "",
"Advanced": "Разширено",
"App": "Приложение",
"Are_You_Sure": "Сигурен ли си?",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "",
"Added_by": "",
"Added_on": "",
"Admin": "",
"Advanced": "",
"Alignment": "",
"Amount": "Quantitat",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Přidáno na nákupní seznam",
"Added_by": "Přidáno uživatelem",
"Added_on": "Přidáno v",
"Admin": "",
"Advanced": "Rozšířené",
"Alignment": "Zarovnání",
"Amount": "Množství",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Tilføjet til indkøbslisten",
"Added_by": "Tilføjet af",
"Added_on": "Tilføjet den",
"Admin": "",
"Advanced": "Avanceret",
"Alignment": "Justering",
"Amount": "Mængde",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Added_To_Shopping_List": "Zur Einkaufsliste hinzugefügt",
"Added_by": "Hinzugefügt durch",
"Added_on": "Hinzugefügt am",
"Admin": "Admin",
"Advanced": "Erweitert",
"Alignment": "Ausrichtung",
"Amount": "Menge",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Προστέθηκε στη λίστα αγορών",
"Added_by": "Προστέθηκε από",
"Added_on": "Προστέθηκε στις",
"Admin": "",
"Advanced": "Για προχωρημένους",
"Amount": "Ποσότητα",
"App": "Εφαρμογή",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Added to shopping list",
"Added_by": "Added By",
"Added_on": "Added On",
"Admin": "Admin",
"Advanced": "Advanced",
"Alignment": "Alignment",
"Amount": "Amount",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Añadido a la lista de la compra",
"Added_by": "Añadido por",
"Added_on": "Añadido el",
"Admin": "",
"Advanced": "Avanzado",
"Alignment": "Alineación",
"Amount": "Cantidad",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"Add_to_Plan": "Lisää suunnitelmaan",
"Add_to_Shopping": "Lisää ostoksiin",
"Added_To_Shopping_List": "Lisätty ostoslistaan",
"Admin": "",
"Advanced Search Settings": "Tarkennetun Haun Asetukset",
"Auto_Planner": "Automaattinen Suunnittelija",
"Automate": "Automatisoi",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Ajouté à la liste de courses",
"Added_by": "Ajouté par",
"Added_on": "Ajouté le",
"Admin": "",
"Advanced": "Avancé",
"Advanced Search Settings": "Paramètres de recherche avancée",
"Alignment": "Alignement",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "נוסף לרשימת הקניות",
"Added_by": "נוסף ע\"י",
"Added_on": "נוסף ב",
"Admin": "",
"Advanced": "מתקדם",
"Alignment": "יישור",
"Amount": "כמות",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Hozzáadva a bevásárlólistához",
"Added_by": "Hozzádta",
"Added_on": "Hozzáadva",
"Admin": "",
"Advanced": "Haladó",
"Alignment": "Igazítás",
"Amount": "Összeg",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/hy.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"Add_to_Book": "",
"Add_to_Plan": "Ավելացնել պլանին",
"Add_to_Shopping": "Ավելացնել գնումներին",
"Admin": "",
"Advanced Search Settings": "Ընդլայնված փնտրման կարգավորումներ",
"Automate": "Ավտոմատացնել",
"Available": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "",
"Added_by": "",
"Added_on": "",
"Admin": "",
"Advanced": "",
"App": "",
"Are_You_Sure": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/is.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "",
"Added_by": "",
"Added_on": "",
"Admin": "",
"Advanced": "",
"Alignment": "",
"Amount": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Aggiunto alla lista della spesa",
"Added_by": "Aggiunto da",
"Added_on": "Aggiunto il",
"Admin": "",
"Advanced": "Avanzate",
"Advanced Search Settings": "Impostazioni avanzate di ricerca",
"Amount": "Quantità",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "",
"Added_by": "",
"Added_on": "",
"Admin": "",
"Advanced": "",
"Alignment": "",
"Amount": "Suma",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/nb_NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Lagt til i handlelisten",
"Added_by": "Lagt til av",
"Added_on": "Lagt til",
"Admin": "",
"Advanced": "Avansert",
"Alignment": "Justering",
"Amount": "Mengde",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Added_To_Shopping_List": "Toegevoegd aan boodschappenlijst",
"Added_by": "Toegevoegd door",
"Added_on": "Toegevoegd op",
"Admin": "",
"Advanced": "Geavanceerd",
"Advanced Search Settings": "Geavanceerde zoekinstellingen",
"Amount": "Hoeveelheid",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Dodano do listy zakupów",
"Added_by": "Dodane przez",
"Added_on": "Dodano dnia",
"Admin": "",
"Advanced": "Zaawansowany",
"Advanced Search Settings": "Ustawienia zaawansowanego wyszukiwania",
"Alignment": "Wyrównanie",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"Added_To_Shopping_List": "Adicionado à lista de compras",
"Added_by": "Adicionado por",
"Added_on": "Adicionado a",
"Admin": "",
"Advanced": "Avançado",
"Amount": "Quantidade",
"Auto_Planner": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Incluído na lista de compras",
"Added_by": "Incluído Por",
"Added_on": "Incluído Em",
"Admin": "",
"Advanced": "Avançado",
"Alignment": "Alinhamento",
"Amount": "Quantidade",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Adăugat la lista de cumpărături",
"Added_by": "Adăugat de",
"Added_on": "Adăugat la",
"Admin": "",
"Advanced": "Avansat",
"Advanced Search Settings": "",
"Amount": "Cantitate",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"Added_To_Shopping_List": "Добавлено в список покупок",
"Added_by": "Добавлено",
"Added_on": "Добавлено на",
"Admin": "",
"Advanced": "Расширенный",
"Advanced Search Settings": "",
"Are_You_Sure": "Вы уверены?",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"Add_to_Shopping": "Dodaj v nakupovalni listek",
"Added_To_Shopping_List": "Dodano v nakupovalni listek",
"Added_by": "Dodano s strani",
"Admin": "",
"Advanced Search Settings": "",
"Amount": "Količina",
"Auto_Planner": "Avto-planer",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Added_To_Shopping_List": "Lades till i inköpslistan",
"Added_by": "Tillagd av",
"Added_on": "Tillagd på",
"Admin": "",
"Advanced": "Avancerat",
"Alignment": "Orientering",
"Amount": "Mängd",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "Alışveriş listesine eklendi",
"Added_by": "Ekleyen",
"Added_on": "Eklenme Zamanı",
"Admin": "",
"Advanced": "Gelişmiş",
"Alignment": "Hizalama",
"Amount": "Miktar",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"Added_To_Shopping_List": "Додано до списку покупок",
"Added_by": "Додано",
"Added_on": "Додано На",
"Admin": "",
"Advanced": "",
"Amount": "Кількість",
"App": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/zh_Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Added_To_Shopping_List": "添加到购物清单",
"Added_by": "添加者",
"Added_on": "添加到",
"Admin": "",
"Advanced": "高级",
"Alignment": "校准",
"Amount": "数量",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/zh_Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"Add_nutrition_recipe": "為食譜添加營養資訊",
"Add_to_Plan": "加入計劃",
"Add_to_Shopping": "加入購物清單",
"Admin": "",
"Available": "",
"AvailableCategories": "",
"BaseUnit": "",
Expand Down
5 changes: 5 additions & 0 deletions vue3/src/openapi/apis/ApiApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@ export interface ApiRecipeListRequest {
keywordsOrNot?: Array<number>;
makenow?: boolean;
_new?: string;
numRecent?: number;
page?: number;
pageSize?: number;
query?: string;
Expand Down Expand Up @@ -8763,6 +8764,10 @@ export class ApiApi extends runtime.BaseAPI {
queryParameters['new'] = requestParameters['_new'];
}

if (requestParameters['numRecent'] != null) {
queryParameters['num_recent'] = requestParameters['numRecent'];
}

if (requestParameters['page'] != null) {
queryParameters['page'] = requestParameters['page'];
}
Expand Down
24 changes: 24 additions & 0 deletions vue3/src/openapi/models/PatchedUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ export interface PatchedUser {
* @memberof PatchedUser
*/
readonly displayName?: string;
/**
* Designates whether the user can log into this admin site.
* @type {boolean}
* @memberof PatchedUser
*/
isStaff?: boolean;
/**
* Designates that this user has all permissions without explicitly assigning them.
* @type {boolean}
* @memberof PatchedUser
*/
isSuperuser?: boolean;
/**
* Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
* @type {boolean}
* @memberof PatchedUser
*/
isActive?: boolean;
}

/**
Expand All @@ -73,6 +91,9 @@ export function PatchedUserFromJSONTyped(json: any, ignoreDiscriminator: boolean
'firstName': json['first_name'] == null ? undefined : json['first_name'],
'lastName': json['last_name'] == null ? undefined : json['last_name'],
'displayName': json['display_name'] == null ? undefined : json['display_name'],
'isStaff': json['is_staff'] == null ? undefined : json['is_staff'],
'isSuperuser': json['is_superuser'] == null ? undefined : json['is_superuser'],
'isActive': json['is_active'] == null ? undefined : json['is_active'],
};
}

Expand All @@ -90,6 +111,9 @@ export function PatchedUserToJSONTyped(value?: Omit<PatchedUser, 'username'|'dis
'id': value['id'],
'first_name': value['firstName'],
'last_name': value['lastName'],
'is_staff': value['isStaff'],
'is_superuser': value['isSuperuser'],
'is_active': value['isActive'],
};
}

Loading

0 comments on commit dc58b42

Please sign in to comment.