Skip to content
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

Moved sulten #925

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/root/management/commands/seed_cypress.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

from root.constants import Environment
from samfundet.models.general import (
Venue,
InformationPage,
ClosedPeriod,
)
from samfundet.models.venue import Venue

User = get_user_model()

Expand Down
2 changes: 1 addition & 1 deletion backend/root/management/commands/seed_scripts/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
EventAgeRestriction,
NonMemberEmailRegistration,
)
from samfundet.models.general import Venue
from samfundet.models.venue import Venue

# Number of events
COUNT = 300
Expand Down
2 changes: 1 addition & 1 deletion backend/root/management/commands/seed_scripts/menu.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random

from root.utils.samfundet_random import words
from samfundet.models.general import Menu, MenuItem, FoodCategory, FoodPreference
from sulten.models import Menu, MenuItem, FoodCategory, FoodPreference

preferences = [
('Vegetar', 'Vegetarian'),
Expand Down
2 changes: 1 addition & 1 deletion backend/root/management/commands/seed_scripts/venues.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.utils.text import slugify

from root.utils.samfundet_random import words
from samfundet.models.general import Venue
from samfundet.models.venue import Venue

VENUES = [
'Storsalen',
Expand Down
4 changes: 4 additions & 0 deletions backend/root/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
NOTIFICATIONS_NOTIFICATION_MODEL = 'samfundet.Notification'
### End: django-notifications-hq ###

### SULTEN ###

INSTALLED_APPS += ['sulten']

################## LOGGING ##################

from root.utils.json_formatter import JsonFormatter # noqa: E402
Expand Down
1 change: 1 addition & 0 deletions backend/root/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
path('admin/', admin.site.urls),
path('rest_framework/', include('rest_framework.urls')),
path('notifications/', include(notifications.urls, namespace='notifications')),
path('', include('sulten.urls')),
path('', include('samfundet.urls')), # Put last.
]

Expand Down
4 changes: 2 additions & 2 deletions backend/root/utils/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class CustomBaseModel(FullCleanSaveMixin):
)

created_by = models.ForeignKey(
'User',
'samfundet.User',
null=True,
blank=True,
on_delete=models.SET_NULL,
Expand All @@ -209,7 +209,7 @@ class CustomBaseModel(FullCleanSaveMixin):
)

updated_by = models.ForeignKey(
'User',
'samfundet.User',
null=True,
blank=True,
on_delete=models.SET_NULL,
Expand Down
80 changes: 40 additions & 40 deletions backend/root/utils/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,50 +215,50 @@
admin__samfundet_table_delete = 'admin:samfundet_table_delete'
admin__samfundet_table_change = 'admin:samfundet_table_change'
adminsamfundettable__objectId = ''
admin__samfundet_reservation_permissions = 'admin:samfundet_reservation_permissions'
admin__samfundet_reservation_permissions_manage_user = 'admin:samfundet_reservation_permissions_manage_user'
admin__samfundet_reservation_permissions_manage_group = 'admin:samfundet_reservation_permissions_manage_group'
admin__samfundet_reservation_changelist = 'admin:samfundet_reservation_changelist'
admin__samfundet_reservation_add = 'admin:samfundet_reservation_add'
admin__samfundet_reservation_history = 'admin:samfundet_reservation_history'
admin__samfundet_reservation_delete = 'admin:samfundet_reservation_delete'
admin__samfundet_reservation_change = 'admin:samfundet_reservation_change'
admin__samfundet_reservation_permissions = 'admin:sulten_reservation_permissions'
admin__samfundet_reservation_permissions_manage_user = 'admin:sulten_reservation_permissions_manage_user'
admin__samfundet_reservation_permissions_manage_group = 'admin:sulten_reservation_permissions_manage_group'
admin__samfundet_reservation_changelist = 'admin:sulten_reservation_changelist'
admin__samfundet_reservation_add = 'admin:sulten_reservation_add'
admin__samfundet_reservation_history = 'admin:sulten_reservation_history'
admin__samfundet_reservation_delete = 'admin:sulten_reservation_delete'
admin__samfundet_reservation_change = 'admin:sulten_reservation_change'
adminsamfundetreservation__objectId = ''
admin__samfundet_menu_permissions = 'admin:samfundet_menu_permissions'
admin__samfundet_menu_permissions_manage_user = 'admin:samfundet_menu_permissions_manage_user'
admin__samfundet_menu_permissions_manage_group = 'admin:samfundet_menu_permissions_manage_group'
admin__samfundet_menu_changelist = 'admin:samfundet_menu_changelist'
admin__samfundet_menu_add = 'admin:samfundet_menu_add'
admin__samfundet_menu_history = 'admin:samfundet_menu_history'
admin__samfundet_menu_delete = 'admin:samfundet_menu_delete'
admin__samfundet_menu_change = 'admin:samfundet_menu_change'
admin__samfundet_menu_permissions = 'admin:sulten_menu_permissions'
admin__samfundet_menu_permissions_manage_user = 'admin:sulten_menu_permissions_manage_user'
admin__samfundet_menu_permissions_manage_group = 'admin:sulten_menu_permissions_manage_group'
admin__samfundet_menu_changelist = 'admin:sulten_menu_changelist'
admin__samfundet_menu_add = 'admin:sulten_menu_add'
admin__samfundet_menu_history = 'admin:sulten_menu_history'
admin__samfundet_menu_delete = 'admin:sulten_menu_delete'
admin__samfundet_menu_change = 'admin:sulten_menu_change'
adminsamfundetmenu__objectId = ''
admin__samfundet_menuitem_permissions = 'admin:samfundet_menuitem_permissions'
admin__samfundet_menuitem_permissions_manage_user = 'admin:samfundet_menuitem_permissions_manage_user'
admin__samfundet_menuitem_permissions_manage_group = 'admin:samfundet_menuitem_permissions_manage_group'
admin__samfundet_menuitem_changelist = 'admin:samfundet_menuitem_changelist'
admin__samfundet_menuitem_add = 'admin:samfundet_menuitem_add'
admin__samfundet_menuitem_history = 'admin:samfundet_menuitem_history'
admin__samfundet_menuitem_delete = 'admin:samfundet_menuitem_delete'
admin__samfundet_menuitem_change = 'admin:samfundet_menuitem_change'
admin__samfundet_menuitem_permissions = 'admin:sulten_menuitem_permissions'
admin__samfundet_menuitem_permissions_manage_user = 'admin:sulten_menuitem_permissions_manage_user'
admin__samfundet_menuitem_permissions_manage_group = 'admin:sulten_menuitem_permissions_manage_group'
admin__samfundet_menuitem_changelist = 'admin:sulten_menuitem_changelist'
admin__samfundet_menuitem_add = 'admin:sulten_menuitem_add'
admin__samfundet_menuitem_history = 'admin:sulten_menuitem_history'
admin__samfundet_menuitem_delete = 'admin:sulten_menuitem_delete'
admin__samfundet_menuitem_change = 'admin:sulten_menuitem_change'
adminsamfundetmenuitem__objectId = ''
admin__samfundet_foodcategory_permissions = 'admin:samfundet_foodcategory_permissions'
admin__samfundet_foodcategory_permissions_manage_user = 'admin:samfundet_foodcategory_permissions_manage_user'
admin__samfundet_foodcategory_permissions_manage_group = 'admin:samfundet_foodcategory_permissions_manage_group'
admin__samfundet_foodcategory_changelist = 'admin:samfundet_foodcategory_changelist'
admin__samfundet_foodcategory_add = 'admin:samfundet_foodcategory_add'
admin__samfundet_foodcategory_history = 'admin:samfundet_foodcategory_history'
admin__samfundet_foodcategory_delete = 'admin:samfundet_foodcategory_delete'
admin__samfundet_foodcategory_change = 'admin:samfundet_foodcategory_change'
admin__samfundet_foodcategory_permissions = 'admin:sulten_foodcategory_permissions'
admin__samfundet_foodcategory_permissions_manage_user = 'admin:sulten_foodcategory_permissions_manage_user'
admin__samfundet_foodcategory_permissions_manage_group = 'admin:sulten_foodcategory_permissions_manage_group'
admin__samfundet_foodcategory_changelist = 'admin:sulten_foodcategory_changelist'
admin__samfundet_foodcategory_add = 'admin:sulten_foodcategory_add'
admin__samfundet_foodcategory_history = 'admin:sulten_foodcategory_history'
admin__samfundet_foodcategory_delete = 'admin:sulten_foodcategory_delete'
admin__samfundet_foodcategory_change = 'admin:sulten_foodcategory_change'
adminsamfundetfoodcategory__objectId = ''
admin__samfundet_foodpreference_permissions = 'admin:samfundet_foodpreference_permissions'
admin__samfundet_foodpreference_permissions_manage_user = 'admin:samfundet_foodpreference_permissions_manage_user'
admin__samfundet_foodpreference_permissions_manage_group = 'admin:samfundet_foodpreference_permissions_manage_group'
admin__samfundet_foodpreference_changelist = 'admin:samfundet_foodpreference_changelist'
admin__samfundet_foodpreference_add = 'admin:samfundet_foodpreference_add'
admin__samfundet_foodpreference_history = 'admin:samfundet_foodpreference_history'
admin__samfundet_foodpreference_delete = 'admin:samfundet_foodpreference_delete'
admin__samfundet_foodpreference_change = 'admin:samfundet_foodpreference_change'
admin__samfundet_foodpreference_permissions = 'admin:sulten_foodpreference_permissions'
admin__samfundet_foodpreference_permissions_manage_user = 'admin:sulten_foodpreference_permissions_manage_user'
admin__samfundet_foodpreference_permissions_manage_group = 'admin:sulten_foodpreference_permissions_manage_group'
admin__samfundet_foodpreference_changelist = 'admin:sulten_foodpreference_changelist'
admin__samfundet_foodpreference_add = 'admin:sulten_foodpreference_add'
admin__samfundet_foodpreference_history = 'admin:sulten_foodpreference_history'
admin__samfundet_foodpreference_delete = 'admin:sulten_foodpreference_delete'
admin__samfundet_foodpreference_change = 'admin:sulten_foodpreference_change'
adminsamfundetfoodpreference__objectId = ''
admin__samfundet_saksdokument_permissions = 'admin:samfundet_saksdokument_permissions'
admin__samfundet_saksdokument_permissions_manage_user = 'admin:samfundet_saksdokument_permissions_manage_user'
Expand Down
143 changes: 40 additions & 103 deletions backend/samfundet/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,22 @@
from .models.general import (
Tag,
User,
Menu,
Gang,
Venue,
Table,
Image,
Campus,
Profile,
Booking,
Infobox,
MenuItem,
GangType,
TextItem,
KeyValue,
BlogPost,
Organization,
Reservation,
ClosedPeriod,
Saksdokument,
FoodCategory,
FoodPreference,
UserPreference,
InformationPage,
)
from .models.venue import Table, Reservation, Booking, Venue

# Common fields:
# ordering = []
Expand Down Expand Up @@ -341,88 +334,6 @@ class BlogPostAdmin(CustomBaseAdmin):
list_select_related = True


@admin.register(Table)
class TableAdmin(CustomBaseAdmin):
# ordering = []
sortable_by = ['id', 'name_nb', 'name_en', 'seating', 'created_at', 'updated_at']
# list_filter = []
list_display = ['id', '__str__', 'name_nb', 'name_en', 'seating', 'created_at', 'updated_at']
search_fields = ['id', 'name_nb', 'name_en']
# filter_horizontal = []
list_display_links = ['id', '__str__']
# autocomplete_fields = []
list_select_related = True


@admin.register(Reservation)
class ReservationAdmin(CustomBaseAdmin):
# ordering = []
sortable_by = ['id', 'name', 'email', 'phonenumber']
# list_filter = []
list_display = ['id', '__str__', 'name', 'email', 'phonenumber']
search_fields = ['id', 'name', 'email', 'phonenumber']
# filter_horizontal = []
list_display_links = ['id', '__str__']
# autocomplete_fields = []
list_select_related = True


@admin.register(Menu)
class MenuAdmin(CustomBaseAdmin):
# ordering = []
sortable_by = ['id', 'name_nb', 'name_en', 'created_at', 'updated_at']
# list_filter = []
list_display = ['id', '__str__', 'name_nb', 'name_en', 'menu_item_count', 'created_at', 'updated_at']
search_fields = ['id', 'name_nb', 'name_en']
filter_horizontal = ['menu_items']
list_display_links = ['id', '__str__']
# autocomplete_fields = []
list_select_related = True

def menu_item_count(self, obj: Menu) -> int:
n: int = obj.menu_items.all().count()
return n


@admin.register(MenuItem)
class MenuItemAdmin(CustomBaseAdmin):
# ordering = []
sortable_by = ['id', 'name_nb', 'name_en', 'price', 'price_member', 'order', 'created_at', 'updated_at']
# list_filter = []
list_display = ['id', '__str__', 'name_nb', 'name_en', 'price', 'price_member', 'order', 'created_at', 'updated_at']
search_fields = ['id', 'name_nb', 'name_en']
filter_horizontal = ['food_preferences']
list_display_links = ['id', '__str__']
# autocomplete_fields = []
list_select_related = True


@admin.register(FoodCategory)
class FoodCategoryAdmin(CustomBaseAdmin):
# ordering = []
sortable_by = ['id', 'name_nb', 'name_en', 'order', 'created_at', 'updated_at']
# list_filter = []
list_display = ['id', '__str__', 'name_nb', 'name_en', 'order', 'created_at', 'updated_at']
search_fields = ['id', 'name_nb', 'name_en']
# filter_horizontal = []
list_display_links = ['id', '__str__']
# autocomplete_fields = []
list_select_related = True


@admin.register(FoodPreference)
class FoodPreferenceAdmin(CustomBaseAdmin):
# ordering = []
sortable_by = ['id', 'name_nb', 'name_en', 'created_at', 'updated_at']
# list_filter = []
list_display = ['id', '__str__', 'name_nb', 'name_en', 'created_at', 'updated_at']
search_fields = ['id', 'name_nb', 'name_en']
# filter_horizontal = []
list_display_links = ['id', '__str__']
# autocomplete_fields = []
list_select_related = True


@admin.register(Saksdokument)
class SaksdokumentAdmin(CustomBaseAdmin):
# ordering = []
Expand All @@ -435,19 +346,6 @@ class SaksdokumentAdmin(CustomBaseAdmin):
# autocomplete_fields = []


@admin.register(Booking)
class BookingAdmin(CustomBaseAdmin):
# ordering = []
# list_filter = []
list_display = ['id', '__str__', 'name', 'get_duration', 'table_count', 'created_at', 'updated_at']
_user_search_fields = UserAdmin.custom_search_fields(prefix='user')
search_fields = ['id', 'name', *_user_search_fields]
filter_horizontal = ['tables']
list_display_links = ['id', '__str__']
autocomplete_fields = ['user']
list_select_related = True


@admin.register(ClosedPeriod)
class ClosedPeriodAdmin(CustomBaseAdmin):
# ordering = []
Expand Down Expand Up @@ -598,4 +496,43 @@ class InterviewAdmin(CustomBaseAdmin):
list_display_links = ['id', 'notes']


@admin.register(Table)
class TableAdmin(CustomBaseAdmin):
# ordering = []
sortable_by = ['id', 'name_nb', 'name_en', 'seating', 'created_at', 'updated_at']
# list_filter = []
list_display = ['id', '__str__', 'name_nb', 'name_en', 'seating', 'created_at', 'updated_at']
search_fields = ['id', 'name_nb', 'name_en']
# filter_horizontal = []
list_display_links = ['id', '__str__']
# autocomplete_fields = []
list_select_related = True


@admin.register(Reservation)
class ReservationAdmin(CustomBaseAdmin):
# ordering = []
sortable_by = ['id', 'name', 'email', 'phonenumber']
# list_filter = []
list_display = ['id', '__str__', 'name', 'email', 'phonenumber']
search_fields = ['id', 'name', 'email', 'phonenumber']
# filter_horizontal = []
list_display_links = ['id', '__str__']
# autocomplete_fields = []
list_select_related = True


@admin.register(Booking)
class BookingAdmin(CustomBaseAdmin):
# ordering = []
# list_filter = []
list_display = ['id', '__str__', 'name', 'get_duration', 'table_count', 'created_at', 'updated_at']
_user_search_fields = UserAdmin.custom_search_fields(prefix='user')
search_fields = ['id', 'name', *_user_search_fields]
filter_horizontal = ['tables']
list_display_links = ['id', '__str__']
autocomplete_fields = ['user']
list_select_related = True


### End: Our models ###
4 changes: 2 additions & 2 deletions backend/samfundet/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from samfundet.constants import DEV_PASSWORD
from samfundet.models.billig import BilligEvent
from samfundet.models.event import Event
from samfundet.models.venue import Table, Reservation, Venue
from samfundet.models.model_choices import EventAgeRestriction, EventTicketType
from samfundet.models.recruitment import Recruitment, RecruitmentPosition, RecruitmentAdmission
from samfundet.models.general import User, Image, InformationPage, Organization, Gang, BlogPost, TextItem, Venue, Table, Reservation

from samfundet.models.general import User, Image, InformationPage, Organization, Gang, BlogPost, TextItem
import root.management.commands.seed_scripts.billig as billig_seed
"""
This module contains fixtures available in pytests.
Expand Down
Loading
Loading