diff --git a/amelie/companies/graphql.py b/amelie/companies/graphql.py new file mode 100644 index 0000000..e98d9a5 --- /dev/null +++ b/amelie/companies/graphql.py @@ -0,0 +1,102 @@ +from django.utils.translation import gettext_lazy as _ +import graphene +from graphene_django import DjangoObjectType + +from amelie.companies.models import Company, WebsiteBanner, TelevisionBanner, VivatBanner +from amelie.graphql.pagination.connection_field import DjangoPaginationConnectionField + + +# Note: Company events are implemented in the calendar module (amelie/calendar/graphql.py) + +class CompanyType(DjangoObjectType): + class Meta: + model = Company + description = "Type definition of a single Company" + filter_fields = { + "name_nl": ("icontains", "iexact"), + "name_en": ("icontains", "iexact"), + } + fields = ["name_nl", "name_en", "slug", "url", "logo", "logo_width", "logo_height", "profile_nl", "profile_en", + "short_description_nl", "short_description_en", "start_date", "end_date", "show_in_app", "app_logo", + "app_logo_height", "app_logo_width"] + + name = graphene.String(description=_("Name of the company")) + profile = graphene.String(description=_("Profile of the company")) + short_description = graphene.String(description=_("Short description of the company")) + + +class WebsiteBannerType(DjangoObjectType): + class Meta: + model = WebsiteBanner + description = "Type definition of a single Website Banner" + filter_fields = { + "name": ("icontains", "iexact"), + } + fields = ["picture", "name", "slug", "start_date", "end_date", "active", "url"] + + +class TelevisionBannerType(DjangoObjectType): + class Meta: + model = TelevisionBanner + description = "Type definition of a single Television Banner" + filter_fields = { + "name": ("icontains", "iexact"), + } + fields = ["picture", "name", "slug", "start_date", "end_date", "active"] + + +class VivatBannerType(DjangoObjectType): + class Meta: + model = VivatBanner + description = "Type definition of a single Vivat Banner" + filter_fields = { + "name": ("icontains", "iexact"), + } + fields = ["picture", "name", "slug", "start_date", "end_date", "active", "url"] + + +class CompaniesQuery(graphene.ObjectType): + company = graphene.Field(CompanyType, id=graphene.ID(), slug=graphene.String()) + companies = DjangoPaginationConnectionField(CompanyType) + + website_banner = graphene.Field(WebsiteBannerType, id=graphene.ID(), slug=graphene.String()) + website_banners = DjangoPaginationConnectionField(WebsiteBannerType) + + television_banner = graphene.Field(TelevisionBannerType, id=graphene.ID(), slug=graphene.String()) + television_banners = DjangoPaginationConnectionField(TelevisionBannerType) + + vivat_banner = graphene.Field(VivatBannerType, id=graphene.ID(), slug=graphene.String()) + vivat_banners = DjangoPaginationConnectionField(VivatBannerType) + + def resolve_company(self, info, id=None, slug=None): + if id is not None: + return Company.objects.get(pk=id) + if slug is not None: + return Company.objects.get(slug=slug) + return None + + def resolve_website_banner(self, info, id=None, slug=None): + if id is not None: + return WebsiteBanner.objects.get(pk=id) + if slug is not None: + return WebsiteBanner.objects.get(slug=slug) + return None + + def resolve_television_banner(self, info, id=None, slug=None): + if id is not None: + return TelevisionBanner.objects.get(pk=id) + if slug is not None: + return TelevisionBanner.objects.get(slug=slug) + return None + + def resolve_vivat_banner(self, info, id=None, slug=None): + if id is not None: + return VivatBanner.objects.get(pk=id) + if slug is not None: + return VivatBanner.objects.get(slug=slug) + return None + + +# Exports +GRAPHQL_QUERIES = [CompaniesQuery] +GRAPHQL_MUTATIONS = [] diff --git a/amelie/settings/generic.py b/amelie/settings/generic.py index acada6c..3d1c81c 100644 --- a/amelie/settings/generic.py +++ b/amelie/settings/generic.py @@ -402,6 +402,7 @@ GRAPHQL_SCHEMAS = [ "amelie.activities.graphql", + "amelie.companies.graphql", "amelie.education.graphql", "amelie.files.graphql", "amelie.members.graphql", diff --git a/locale/nl/LC_MESSAGES/django.mo b/locale/nl/LC_MESSAGES/django.mo index 6a11044..356d712 100644 Binary files a/locale/nl/LC_MESSAGES/django.mo and b/locale/nl/LC_MESSAGES/django.mo differ diff --git a/locale/nl/LC_MESSAGES/django.po b/locale/nl/LC_MESSAGES/django.po index be28812..0206501 100644 --- a/locale/nl/LC_MESSAGES/django.po +++ b/locale/nl/LC_MESSAGES/django.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-11-13 23:31+0100\n" -"PO-Revision-Date: 2023-11-13 23:32+0018\n" +"POT-Creation-Date: 2023-12-11 22:08+0100\n" +"PO-Revision-Date: 2023-12-11 22:09+0018\n" "Last-Translator: <>\n" "Language: en\n" "MIME-Version: 1.0\n" @@ -1588,11 +1588,6 @@ msgid "Photo archive" msgstr "Foto-archief" #: amelie/activities/templates/gallery_overview.html:245 -#| msgid "" -#| "\n" -#| " The photo archive with photos from 2000 till march 2009 can be found on\n" -#| " foto.inter-actief.net.\n" -#| " " msgid "" "\n" " The photo archive with photos from 2000 till march 2009 can be found on\n" @@ -3089,6 +3084,21 @@ msgstr "Begin:" msgid "End (till)" msgstr "Einde (tot):" +#: amelie/companies/graphql.py:23 +#| msgid "Name (company)" +msgid "Name of the company" +msgstr "Naam van het bedrijf" + +#: amelie/companies/graphql.py:24 +#| msgid "Subject of the complaint" +msgid "Profile of the company" +msgstr "Profiel van het bedrijf" + +#: amelie/companies/graphql.py:25 +#| msgid "short description (en)" +msgid "Short description of the company" +msgstr "Korte beschrijving van het bedrijf" + #: amelie/companies/models.py:18 amelie/personal_tab/models.py:421 msgid "name" msgstr "naam" @@ -10053,19 +10063,19 @@ msgstr "Nederlands" msgid "English" msgstr "Engels" -#: amelie/settings/generic.py:701 +#: amelie/settings/generic.py:702 msgid "Access to your name, date of birth, student number, mandate status and committee status." msgstr "Toegang tot je naam, geboortedatum, studentnummer, machtiging- en commissiestatus" -#: amelie/settings/generic.py:702 +#: amelie/settings/generic.py:703 msgid "Access to enrollments for activities and (un)enrolling you for activities." msgstr "Toegang tot inschrijvingen voor activiteiten en het in- en uitschrijven voor activiteiten" -#: amelie/settings/generic.py:703 +#: amelie/settings/generic.py:704 msgid "Access to transactions, direct debit transactions, mandates and RFID-cards." msgstr "Toegang tot transacties, incasso's, machtigingen en RFID-kaarten" -#: amelie/settings/generic.py:704 +#: amelie/settings/generic.py:705 msgid "Access to complaints and sending or supporting complaints in your name." msgstr "Toegang tot onderwijsklachten en het indienen of steunen van onderwijsklachten"