Show related events
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
a877e4d7d9
commit
f5b02ed154
|
@ -43,6 +43,7 @@ export const FETCH_EVENT = gql`
|
|||
organizerActor {
|
||||
avatarUrl,
|
||||
preferredUsername,
|
||||
domain,
|
||||
name,
|
||||
},
|
||||
# attributedTo {
|
||||
|
@ -56,6 +57,20 @@ export const FETCH_EVENT = gql`
|
|||
tags {
|
||||
slug,
|
||||
title
|
||||
},
|
||||
relatedEvents {
|
||||
uuid,
|
||||
title,
|
||||
beginsOn,
|
||||
physicalAddress {
|
||||
description
|
||||
},
|
||||
organizerActor {
|
||||
avatarUrl,
|
||||
preferredUsername,
|
||||
domain,
|
||||
name,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: mobilizon 0.1.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-04-10 16:31+0200\n"
|
||||
"POT-Creation-Date: 2019-04-12 16:47+0200\n"
|
||||
"PO-Revision-Date: 2019-04-08 20:58+0200\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
|
@ -29,7 +29,7 @@ msgstr "A validation email was sent to %{email}"
|
|||
msgid "About"
|
||||
msgstr "About"
|
||||
|
||||
#: src/views/Event/Event.vue:138
|
||||
#: src/views/Event/Event.vue:137
|
||||
msgid "About this event"
|
||||
msgstr "About this event"
|
||||
|
||||
|
@ -41,7 +41,7 @@ msgstr "About this instance"
|
|||
msgid "Add a new profile"
|
||||
msgstr "Add a new profile"
|
||||
|
||||
#: src/views/Event/Event.vue:44 src/views/Event/Event.vue:217
|
||||
#: src/views/Event/Event.vue:44 src/views/Event/Event.vue:216
|
||||
msgid "Add to my calendar"
|
||||
msgstr "Add to my calendar"
|
||||
|
||||
|
@ -53,7 +53,7 @@ msgstr "Are you going to this event?"
|
|||
msgid "Before you can login, you need to click on the link inside it to validate your account"
|
||||
msgstr "Before you can login, you need to click on the link inside it to validate your account"
|
||||
|
||||
#: src/views/Event/Event.vue:101
|
||||
#: src/views/Event/Event.vue:100
|
||||
msgid "By %{ name }"
|
||||
msgstr "By %{ name }"
|
||||
|
||||
|
@ -93,7 +93,7 @@ msgstr "Create your communities and your events"
|
|||
msgid "Current"
|
||||
msgstr "Current"
|
||||
|
||||
#: src/views/Account/Profile.vue:93 src/views/Event/Event.vue:64
|
||||
#: src/views/Account/Profile.vue:93 src/views/Event/Event.vue:63
|
||||
msgid "Delete"
|
||||
msgstr "Delete"
|
||||
|
||||
|
@ -101,7 +101,7 @@ msgstr "Delete"
|
|||
msgid "Didn't receive the instructions ?"
|
||||
msgstr "Didn't receive the instructions ?"
|
||||
|
||||
#: src/views/Event/Event.vue:59
|
||||
#: src/views/Event/Event.vue:58
|
||||
msgid "Edit"
|
||||
msgstr "Edit"
|
||||
|
||||
|
@ -205,7 +205,7 @@ msgstr "Members"
|
|||
msgid "My account"
|
||||
msgstr "My account"
|
||||
|
||||
#: src/views/Event/Event.vue:70
|
||||
#: src/views/Event/Event.vue:69
|
||||
msgid "No address defined"
|
||||
msgstr "No address defined"
|
||||
|
||||
|
@ -304,7 +304,7 @@ msgstr "Reset my password"
|
|||
msgid "RSS/Atom Feed"
|
||||
msgstr "RSS/Atom Feed"
|
||||
|
||||
#: src/views/PageNotFound.vue:18 src/components/SearchField.vue:19
|
||||
#: src/views/PageNotFound.vue:19 src/components/SearchField.vue:19
|
||||
msgid "Search"
|
||||
msgstr "Search"
|
||||
|
||||
|
@ -320,11 +320,11 @@ msgstr "Send confirmation email again"
|
|||
msgid "Send email to reset my password"
|
||||
msgstr "Send email to reset my password"
|
||||
|
||||
#: src/views/Event/Event.vue:206
|
||||
#: src/views/Event/Event.vue:205
|
||||
msgid "Share this event"
|
||||
msgstr "Share this event"
|
||||
|
||||
#: src/views/Event/Event.vue:79
|
||||
#: src/views/Event/Event.vue:78
|
||||
msgid "Show map"
|
||||
msgstr "Show map"
|
||||
|
||||
|
@ -340,7 +340,7 @@ msgstr "The %{ date } at %{ time }"
|
|||
msgid "The %{ date } from %{ startTime } to %{ endTime }"
|
||||
msgstr "The %{ date } from %{ startTime } to %{ endTime }"
|
||||
|
||||
#: src/views/Event/Event.vue:141
|
||||
#: src/views/Event/Event.vue:140
|
||||
msgid "The event organizer didn't add any description."
|
||||
msgstr "The event organizer didn't add any description."
|
||||
|
||||
|
@ -348,7 +348,7 @@ msgstr "The event organizer didn't add any description."
|
|||
msgid "The page you're looking for doesn't exist."
|
||||
msgstr ""
|
||||
|
||||
#: src/views/Event/Event.vue:224
|
||||
#: src/views/Event/Event.vue:223
|
||||
msgid "These events may interest you"
|
||||
msgstr "These events may interest you"
|
||||
|
||||
|
@ -434,6 +434,6 @@ msgstr "Your local administrator resumed it's policy:"
|
|||
msgid "World map"
|
||||
msgstr "World map"
|
||||
|
||||
#: src/views/PageNotFound.vue:40
|
||||
#: src/views/PageNotFound.vue:42
|
||||
msgid "Search events, groups, etc."
|
||||
msgstr ""
|
||||
|
|
|
@ -7,8 +7,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: mobilizon 0.1.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-04-10 16:31+0200\n"
|
||||
"PO-Revision-Date: 2019-04-10 16:33+0200\n"
|
||||
"POT-Creation-Date: 2019-04-12 16:47+0200\n"
|
||||
"PO-Revision-Date: 2019-04-12 16:45+0200\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: fr_FR\n"
|
||||
|
@ -30,7 +30,7 @@ msgstr "Un email de validation a été envoyé à %{email}"
|
|||
msgid "About"
|
||||
msgstr "À propos"
|
||||
|
||||
#: src/views/Event/Event.vue:138
|
||||
#: src/views/Event/Event.vue:137
|
||||
msgid "About this event"
|
||||
msgstr "À propos de cet événement"
|
||||
|
||||
|
@ -42,7 +42,7 @@ msgstr "À propos de cette instance"
|
|||
msgid "Add a new profile"
|
||||
msgstr "Ajouter un nouveau profil"
|
||||
|
||||
#: src/views/Event/Event.vue:44 src/views/Event/Event.vue:217
|
||||
#: src/views/Event/Event.vue:44 src/views/Event/Event.vue:216
|
||||
msgid "Add to my calendar"
|
||||
msgstr "Ajouter à mon agenda"
|
||||
|
||||
|
@ -54,7 +54,7 @@ msgstr "Allez-vous à cet événement ?"
|
|||
msgid "Before you can login, you need to click on the link inside it to validate your account"
|
||||
msgstr "Avant que vous puissiez vous enregistrer, vous devez cliquer sur le lien à l'intérieur pour valider votre compte"
|
||||
|
||||
#: src/views/Event/Event.vue:101
|
||||
#: src/views/Event/Event.vue:100
|
||||
msgid "By %{ name }"
|
||||
msgstr "Par %{name}"
|
||||
|
||||
|
@ -94,7 +94,7 @@ msgstr "Créer vos communautés et vos événements"
|
|||
msgid "Current"
|
||||
msgstr "Actuel"
|
||||
|
||||
#: src/views/Account/Profile.vue:93 src/views/Event/Event.vue:64
|
||||
#: src/views/Account/Profile.vue:93 src/views/Event/Event.vue:63
|
||||
msgid "Delete"
|
||||
msgstr "Supprimer"
|
||||
|
||||
|
@ -102,7 +102,7 @@ msgstr "Supprimer"
|
|||
msgid "Didn't receive the instructions ?"
|
||||
msgstr "Vous n'avez pas reçu les instructions ?"
|
||||
|
||||
#: src/views/Event/Event.vue:59
|
||||
#: src/views/Event/Event.vue:58
|
||||
msgid "Edit"
|
||||
msgstr "Éditer"
|
||||
|
||||
|
@ -206,7 +206,7 @@ msgstr "Membres"
|
|||
msgid "My account"
|
||||
msgstr "Mon compte"
|
||||
|
||||
#: src/views/Event/Event.vue:70
|
||||
#: src/views/Event/Event.vue:69
|
||||
msgid "No address defined"
|
||||
msgstr "Aucune adresse définie"
|
||||
|
||||
|
@ -305,7 +305,7 @@ msgstr "Réinitialiser mon mot de passe"
|
|||
msgid "RSS/Atom Feed"
|
||||
msgstr "Flux RSS/Atom"
|
||||
|
||||
#: src/views/PageNotFound.vue:18 src/components/SearchField.vue:19
|
||||
#: src/views/PageNotFound.vue:19 src/components/SearchField.vue:19
|
||||
msgid "Search"
|
||||
msgstr "Rechercher"
|
||||
|
||||
|
@ -321,11 +321,11 @@ msgstr "Envoyer l'email de confirmation à nouveau"
|
|||
msgid "Send email to reset my password"
|
||||
msgstr "Envoyer un email pour réinitialiser mon mot de passe"
|
||||
|
||||
#: src/views/Event/Event.vue:206
|
||||
#: src/views/Event/Event.vue:205
|
||||
msgid "Share this event"
|
||||
msgstr "Partager cet événement"
|
||||
msgstr "Partager l'événement"
|
||||
|
||||
#: src/views/Event/Event.vue:79
|
||||
#: src/views/Event/Event.vue:78
|
||||
msgid "Show map"
|
||||
msgstr "Afficher la carte"
|
||||
|
||||
|
@ -341,7 +341,7 @@ msgstr "Le %{ date } à %{ time }"
|
|||
msgid "The %{ date } from %{ startTime } to %{ endTime }"
|
||||
msgstr "Le %{ date } de %{ startTime } à %{ endTime }"
|
||||
|
||||
#: src/views/Event/Event.vue:141
|
||||
#: src/views/Event/Event.vue:140
|
||||
msgid "The event organizer didn't add any description."
|
||||
msgstr "L'organisateur de l'événement n'a pas ajouté de description."
|
||||
|
||||
|
@ -349,7 +349,7 @@ msgstr "L'organisateur de l'événement n'a pas ajouté de description."
|
|||
msgid "The page you're looking for doesn't exist."
|
||||
msgstr "La page que vous recherchez n'existe pas."
|
||||
|
||||
#: src/views/Event/Event.vue:224
|
||||
#: src/views/Event/Event.vue:223
|
||||
msgid "These events may interest you"
|
||||
msgstr "Ces événements peuvent vous intéresser"
|
||||
|
||||
|
@ -435,6 +435,6 @@ msgstr "Votre administrateur local a résumé sa politique ainsi :"
|
|||
msgid "World map"
|
||||
msgstr "Carte mondiale"
|
||||
|
||||
#: src/views/PageNotFound.vue:40
|
||||
#: src/views/PageNotFound.vue:42
|
||||
msgid "Search events, groups, etc."
|
||||
msgstr "Rechercher des événements, des groupes, etc."
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -69,6 +69,8 @@ export interface IEvent {
|
|||
attributedTo: IActor;
|
||||
participants: IParticipant[];
|
||||
|
||||
relatedEvents: IEvent[];
|
||||
|
||||
onlineAddress?: string;
|
||||
phoneAddress?: string;
|
||||
physicalAddress?: IAddress;
|
||||
|
@ -94,6 +96,7 @@ export class EventModel implements IEvent {
|
|||
visibility: EventVisibility = EventVisibility.PUBLIC;
|
||||
attributedTo: IActor = new Actor();
|
||||
organizerActor: IActor = new Actor();
|
||||
relatedEvents: IEvent[] = [];
|
||||
onlineAddress: string = '';
|
||||
phoneAddress: string = '';
|
||||
}
|
||||
|
|
|
@ -204,12 +204,14 @@
|
|||
<div class="columns">
|
||||
<div class="column is-half has-text-centered">
|
||||
<h3 class="title"><translate>Share this event</translate></h3>
|
||||
<b-icon icon="mastodon" size="is-large" type="is-primary" />
|
||||
<a :href="facebookShareUrl" target="_blank" rel="nofollow noopener"><b-icon icon="facebook" size="is-large" type="is-primary" /></a>
|
||||
<a :href="twitterShareUrl" target="_blank" rel="nofollow noopener"><b-icon icon="twitter" size="is-large" type="is-primary" /></a>
|
||||
<a :href="emailShareUrl" target="_blank" rel="nofollow noopener"><b-icon icon="email" size="is-large" type="is-primary" /></a>
|
||||
<!-- TODO: mailto: links are not used anymore, we should provide a popup to redact a message instead -->
|
||||
<a :href="linkedInShareUrl" target="_blank" rel="nofollow noopener"><b-icon icon="linkedin" size="is-large" type="is-primary" /></a>
|
||||
<div>
|
||||
<b-icon icon="mastodon" size="is-large" type="is-primary" />
|
||||
<a :href="facebookShareUrl" target="_blank" rel="nofollow noopener"><b-icon icon="facebook" size="is-large" type="is-primary" /></a>
|
||||
<a :href="twitterShareUrl" target="_blank" rel="nofollow noopener"><b-icon icon="twitter" size="is-large" type="is-primary" /></a>
|
||||
<a :href="emailShareUrl" target="_blank" rel="nofollow noopener"><b-icon icon="email" size="is-large" type="is-primary" /></a>
|
||||
<!-- TODO: mailto: links are not used anymore, we should provide a popup to redact a message instead -->
|
||||
<a :href="linkedInShareUrl" target="_blank" rel="nofollow noopener"><b-icon icon="linkedin" size="is-large" type="is-primary" /></a>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="column is-half has-text-right add-to-calendar">
|
||||
|
@ -223,8 +225,8 @@
|
|||
<section class="more-events container">
|
||||
<h3 class="title has-text-centered"><translate>These events may interest you</translate></h3>
|
||||
<div class="columns">
|
||||
<div class="column" v-for="index in 3" :key="index">
|
||||
<EventCard :event="event" />
|
||||
<div class="column" v-for="relatedEvent in event.relatedEvents" :key="relatedEvent.uuid">
|
||||
<EventCard :event="relatedEvent" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
@ -57,6 +57,7 @@ defmodule Mobilizon.Events do
|
|||
e.organizer_actor_id == ^actor_id and e.visibility in [^:public, ^:unlisted] and
|
||||
e.begins_on > ^DateTime.utc_now(),
|
||||
order_by: [asc: :begins_on],
|
||||
limit: 1,
|
||||
preload: [
|
||||
:organizer_actor,
|
||||
:tags,
|
||||
|
@ -259,18 +260,42 @@ defmodule Mobilizon.Events do
|
|||
[%Event{}, ...]
|
||||
|
||||
"""
|
||||
def list_events(page \\ nil, limit \\ nil) do
|
||||
@spec list_events(integer(), integer(), atom(), atom()) :: list(Event.t())
|
||||
def list_events(
|
||||
page \\ nil,
|
||||
limit \\ nil,
|
||||
sort \\ :begins_on,
|
||||
direction \\ :asc,
|
||||
unlisted \\ false,
|
||||
future \\ true
|
||||
) do
|
||||
query =
|
||||
from(
|
||||
e in Event,
|
||||
where: e.visibility == ^:public,
|
||||
preload: [:organizer_actor, :participants]
|
||||
)
|
||||
|> paginate(page, limit)
|
||||
|> sort(sort, direction)
|
||||
|> restrict_future_events(future)
|
||||
|> allow_unlisted(unlisted)
|
||||
|
||||
Repo.all(query)
|
||||
end
|
||||
|
||||
# Make sure we only show future events
|
||||
@spec restrict_future_events(Ecto.Query.t(), boolean()) :: Ecto.Query.t()
|
||||
defp restrict_future_events(query, true),
|
||||
do: from(q in query, where: q.begins_on > ^DateTime.utc_now())
|
||||
|
||||
defp restrict_future_events(query, false), do: query
|
||||
|
||||
# Make sure unlisted events don't show up where they're not allowed
|
||||
@spec allow_unlisted(Ecto.Query.t(), boolean()) :: Ecto.Query.t()
|
||||
defp allow_unlisted(query, true),
|
||||
do: from(q in query, where: q.visibility in [^:public, ^:unlisted])
|
||||
|
||||
defp allow_unlisted(query, false), do: from(q in query, where: q.visibility == ^:public)
|
||||
|
||||
@doc """
|
||||
Find events by name
|
||||
"""
|
||||
|
|
|
@ -49,7 +49,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||
List related events
|
||||
"""
|
||||
def list_related_events(
|
||||
%Event{tags: tags, organizer_actor: organizer_actor},
|
||||
%Event{tags: tags, organizer_actor: organizer_actor, uuid: uuid},
|
||||
_args,
|
||||
_resolution
|
||||
) do
|
||||
|
@ -57,12 +57,13 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||
events =
|
||||
[Events.get_actor_upcoming_public_event(organizer_actor, uuid)] |> Enum.filter(&is_map/1)
|
||||
|
||||
# We find similar events with the same tags
|
||||
# uniq_by : It's possible event_from_same_actor is inside events_from_tags
|
||||
events =
|
||||
(events ++
|
||||
Events.find_similar_events_by_common_tags(
|
||||
tags,
|
||||
@number_of_related_events - length(events)
|
||||
@number_of_related_events
|
||||
))
|
||||
|> uniq_events()
|
||||
|
||||
|
@ -85,10 +86,11 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||
# We return only @number_of_related_events right now
|
||||
|> Enum.take(@number_of_related_events)
|
||||
|
||||
# TODO: We should use tag_relations to find more events
|
||||
{:ok, events}
|
||||
end
|
||||
|
||||
defp uniq_events(events), do: Enum.uniq_by(events, fn event -> event.uuid end)
|
||||
|
||||
@doc """
|
||||
Join an event for an actor
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue