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

Add the companies module to the graphql api #826

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
102 changes: 102 additions & 0 deletions amelie/companies/graphql.py
Original file line number Diff line number Diff line change
@@ -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 = []
1 change: 1 addition & 0 deletions amelie/settings/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@

GRAPHQL_SCHEMAS = [
"amelie.activities.graphql",
"amelie.companies.graphql",
"amelie.education.graphql",
"amelie.files.graphql",
"amelie.members.graphql",
Expand Down
Binary file modified locale/nl/LC_MESSAGES/django.mo
Binary file not shown.
32 changes: 21 additions & 11 deletions locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
#| " <a href=\"https://foto.inter-actief.net/\">foto.inter-actief.net</a>.\n"
#| " "
msgid ""
"\n"
" The photo archive with photos from 2000 till march 2009 can be found on\n"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down