diff --git a/backend/root/management/commands/seed_scripts/__init__.py b/backend/root/management/commands/seed_scripts/__init__.py index e80702a9a..ced9e69b5 100755 --- a/backend/root/management/commands/seed_scripts/__init__.py +++ b/backend/root/management/commands/seed_scripts/__init__.py @@ -8,6 +8,7 @@ billig, menu, documents, + textitems, example, samf3, recruitment, @@ -32,6 +33,7 @@ ('menu', menu.seed), ('documents', documents.seed), ('information_page', information_pages.seed), + ('textitems', textitems.seed), ('blogposts', blogposts.seed), ('organization', oganizations.seed), ('recruitment', recruitment.seed), diff --git a/backend/root/management/commands/seed_scripts/textitems.py b/backend/root/management/commands/seed_scripts/textitems.py new file mode 100644 index 000000000..9fa2bd21b --- /dev/null +++ b/backend/root/management/commands/seed_scripts/textitems.py @@ -0,0 +1,44 @@ +from samfundet.models.general import TextItem + + +def seed(): + text_items = [ + { + 'key': 'welcome_message', + 'text_nb': 'Velkommen til Studentersamfundet i Trondhjem!', + 'text_en': 'Welcome to the Student Society in Trondheim!', + }, + { + 'key': 'upcoming_events', + 'text_nb': 'Sjekk ut våre kommende arrangementer og konsertene vi har planlagt!', + 'text_en': 'Check out our upcoming events and concerts we have planned!', + }, + { + 'key': 'join_us', + 'text_nb': 'Bli medlem av Studentersamfundet og nyt godt av medlemsfordelene!', + 'text_en': 'Join the Student Society and enjoy the benefits of membership!', + }, + { + 'key': 'volunteer', + 'text_nb': 'Vil du bli frivillig? Bli med i vårt fantastiske team og bidra til studentkulturen i Trondheim!', + 'text_en': 'Want to volunteer? Join our amazing team and contribute to the student culture in Trondheim!', + }, + { + 'key': 'about_us', + 'text_nb': 'Studentersamfundet i Trondhjem er et kulturelt senter for studenter og en viktig del av studentlivet i Trondheim.', + 'text_en': 'The Student Society in Trondheim is a cultural center for students and an essential part of student life in Trondheim.', + }, + { + 'key': 'contact_us', + 'text_nb': 'Har du spørsmål eller ønsker å komme i kontakt med oss? Ikke nøl med å ta kontakt!', + 'text_en': 'Do you have any questions or want to get in touch with us? Don"t hesitate to contact us!', + }, + ] + + TextItem.objects.all().delete() + yield 0, 'Deleted old textitems' + + for i, item in enumerate(text_items): + text_item, created = TextItem.objects.get_or_create(key=item['key'], text_nb=item['text_nb'], text_en=item['text_en']) + if created: + yield (100 * (i + 1) // len(text_items), f'Created {len(TextItem.objects.all())} textitems')