Merge branch 'fixes' into 'master'

Fix event options being undefined in event view

See merge request framasoft/mobilizon!1084
This commit is contained in:
Thomas Citharel 2021-10-20 14:46:40 +00:00
commit 8acca91dd5
4 changed files with 26 additions and 22 deletions

3
.gitignore vendored
View file

@ -47,4 +47,5 @@ release/
docker/production/.env
test-junit-report.xml
js/junit.xml
.env
.env
demo/

View file

@ -135,17 +135,17 @@
}"
>
<!-- We retire one because of the event creator who is a participant -->
<span v-if="event.options.maximumAttendeeCapacity">
<span v-if="maximumAttendeeCapacity">
{{
$tc(
"{available}/{capacity} available places",
event.options.maximumAttendeeCapacity -
maximumAttendeeCapacity -
event.participantStats.participant,
{
available:
event.options.maximumAttendeeCapacity -
maximumAttendeeCapacity -
event.participantStats.participant,
capacity: event.options.maximumAttendeeCapacity,
capacity: maximumAttendeeCapacity,
}
)
}}
@ -163,17 +163,17 @@
</span>
</router-link>
<span v-else>
<span v-if="event.options.maximumAttendeeCapacity">
<span v-if="maximumAttendeeCapacity">
{{
$tc(
"{available}/{capacity} available places",
event.options.maximumAttendeeCapacity -
maximumAttendeeCapacity -
event.participantStats.participant,
{
available:
event.options.maximumAttendeeCapacity -
maximumAttendeeCapacity -
event.participantStats.participant,
capacity: event.options.maximumAttendeeCapacity,
capacity: maximumAttendeeCapacity,
}
)
}}
@ -1074,20 +1074,23 @@ export default class Event extends EventMixin {
: this.event.beginsOn;
}
get maximumAttendeeCapacity(): number {
return this.event?.options?.maximumAttendeeCapacity;
}
get eventCapacityOK(): boolean {
if (this.event.draft) return true;
if (!this.event.options.maximumAttendeeCapacity) return true;
if (!this.maximumAttendeeCapacity) return true;
return (
this.event.options.maximumAttendeeCapacity >
this.event?.options?.maximumAttendeeCapacity >
this.event.participantStats.participant
);
}
get numberOfPlacesStillAvailable(): number {
if (this.event.draft) return this.event.options.maximumAttendeeCapacity;
if (this.event.draft) return this.maximumAttendeeCapacity;
return (
this.event.options.maximumAttendeeCapacity -
this.event.participantStats.participant
this.maximumAttendeeCapacity - this.event.participantStats.participant
);
}

View file

@ -32,16 +32,10 @@ defmodule Mobilizon.GraphQL.Resolvers.Discussion do
end
end
def find_discussions_for_actor(%Actor{}, _args, %{
context: %{
current_user: %User{}
}
}) do
def find_discussions_for_actor(%Actor{}, _args, _resolution) do
{:ok, %Page{total: 0, elements: []}}
end
def find_discussions_for_actor(%Actor{}, _args, _resolution), do: {:error, :unauthenticated}
@spec get_discussion(any(), map(), Absinthe.Resolution.t()) ::
{:ok, Discussion.t()} | {:error, :unauthorized | :discussion_not_found | String.t()}
def get_discussion(_parent, %{id: id}, %{

View file

@ -22,8 +22,8 @@ defmodule Mobilizon.Posts.Post do
import Ecto.Changeset
alias Ecto.Changeset
alias Mobilizon.Actors.Actor
alias Mobilizon.{Events, Medias}
alias Mobilizon.Events.Tag
alias Mobilizon.Medias
alias Mobilizon.Medias.Media
alias Mobilizon.Posts.Post.TitleSlug
alias Mobilizon.Posts.PostVisibility
@ -141,6 +141,12 @@ defmodule Mobilizon.Posts.Post do
defp put_tags(changeset, _), do: changeset
@spec process_tag(map() | Tag.t()) :: Tag.t() | Ecto.Changeset.t()
# We need a changeset instead of a raw struct because of slug which is generated in changeset
defp process_tag(%{id: id} = _tag) do
Events.get_tag(id)
end
defp process_tag(tag), do: Tag.changeset(%Tag{}, tag)
defp maybe_put_publish_date(%Changeset{} = changeset) do