Export participants to different formats

* CSV
* PDF (requires Python dependency `weasyprint`)
* ODS (requires Python dependency `pyexcel_ods3`)

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-10-04 18:59:41 +02:00
parent 5dd24e1c9e
commit 0c667b13ae
121 changed files with 10817 additions and 6872 deletions

View File

@@ -65,6 +65,8 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
field(:auth, :auth, description: "The instance auth methods")
field(:instance_feeds, :instance_feeds, description: "The instance's feed settings")
field(:web_push, :web_push, description: "Web Push settings for the instance")
field(:export_formats, :export_formats, description: "The instance list of export formats")
end
@desc """
@@ -307,6 +309,15 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
field(:public_key, :string, description: "The server's public WebPush VAPID key")
end
@desc """
Export formats configuration
"""
object :export_formats do
field(:event_participants, list_of(:string),
description: "The list of formats the event participants can be exported to"
)
end
object :config_queries do
@desc "Get the instance config"
field :config, :config do

View File

@@ -70,6 +70,12 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
value(:rejected, description: "The participant has been rejected from this event")
end
enum :export_format_enum do
value(:csv, description: "CSV format")
value(:pdf, description: "PDF format")
value(:ods, description: "ODS format")
end
@desc "Represents a deleted participant"
object :deleted_participant do
field(:id, :id, description: "The participant ID")
@@ -111,5 +117,20 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
arg(:confirmation_token, non_null(:string), description: "The participation token")
resolve(&Participant.confirm_participation_from_token/3)
end
@desc "Export the event participants as a file"
field :export_event_participants, :string do
arg(:event_id, non_null(:id),
description: "The ID from the event for which to export participants"
)
arg(:roles, list_of(:participant_role_enum),
default_value: [],
description: "The participant roles to include"
)
arg(:format, :export_format_enum, description: "The format in which to return the file")
resolve(&Participant.export_event_participants/3)
end
end
end