Split event visibility and join options
Signed-off-by: Thomas Citharel <tcit@tcit.fr> Fix tests Signed-off-by: Thomas Citharel <tcit@tcit.fr> Fix format Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
665e27e485
commit
d8131c21c0
@ -1,11 +1,22 @@
|
|||||||
import { IActor } from "./actor.model";
|
import { IActor } from "./actor.model";
|
||||||
|
|
||||||
export enum EventStatus {
|
export enum EventStatus {
|
||||||
TENTATIVE, CONFIRMED, CANCELLED
|
TENTATIVE,
|
||||||
|
CONFIRMED,
|
||||||
|
CANCELLED
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum EventVisibility {
|
export enum EventVisibility {
|
||||||
PUBLIC, PRIVATE
|
PUBLIC,
|
||||||
|
UNLISTED,
|
||||||
|
RESTRICTED,
|
||||||
|
PRIVATE
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum EventJoinOptions {
|
||||||
|
FREE,
|
||||||
|
RESTRICTED,
|
||||||
|
INVITE
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ParticipantRole {
|
export enum ParticipantRole {
|
||||||
@ -34,6 +45,7 @@ export interface IEvent {
|
|||||||
ends_on: Date;
|
ends_on: Date;
|
||||||
status: EventStatus;
|
status: EventStatus;
|
||||||
visibility: EventVisibility;
|
visibility: EventVisibility;
|
||||||
|
join_options: EventJoinOptions;
|
||||||
thumbnail: string;
|
thumbnail: string;
|
||||||
large_image: string;
|
large_image: string;
|
||||||
publish_at: Date;
|
publish_at: Date;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import {EventJoinOptions} from "../../types/event.model";
|
||||||
<template>
|
<template>
|
||||||
<section>
|
<section>
|
||||||
<h1 class="title">
|
<h1 class="title">
|
||||||
@ -31,22 +32,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// import Location from '@/components/Location';
|
// import Location from '@/components/Location';
|
||||||
import VueMarkdown from "vue-markdown";
|
import VueMarkdown from "vue-markdown";
|
||||||
import { CREATE_EVENT, EDIT_EVENT } from "@/graphql/event";
|
import {CREATE_EVENT, EDIT_EVENT} from "@/graphql/event";
|
||||||
import { FETCH_CATEGORIES } from "@/graphql/category";
|
import {FETCH_CATEGORIES} from "@/graphql/category";
|
||||||
import { AUTH_USER_ACTOR } from "@/constants";
|
import {Component, Prop, Vue} from "vue-property-decorator";
|
||||||
import { Component, Prop, Vue } from "vue-property-decorator";
|
import {EventJoinOptions, EventStatus, EventVisibility, ICategory, IEvent} from "@/types/event.model";
|
||||||
import {
|
import {LOGGED_PERSON} from "@/graphql/actor";
|
||||||
IEvent,
|
import {IPerson} from "@/types/actor.model";
|
||||||
ICategory,
|
|
||||||
EventVisibility,
|
|
||||||
EventStatus
|
|
||||||
} from "../../types/event.model";
|
|
||||||
import { LOGGED_PERSON } from "../../graphql/actor";
|
|
||||||
import { IPerson } from "../../types/actor.model";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
VueMarkdown
|
VueMarkdown
|
||||||
},
|
},
|
||||||
@ -70,7 +65,7 @@ export default class CreateEvent extends Vue {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
// We put initialization here because we need loggedPerson to be ready before initalizing event
|
// We put initialization here because we need loggedPerson to be ready before initializing event
|
||||||
const { data } = await this.$apollo.query({ query: LOGGED_PERSON });
|
const { data } = await this.$apollo.query({ query: LOGGED_PERSON });
|
||||||
|
|
||||||
this.loggedPerson = data.loggedPerson;
|
this.loggedPerson = data.loggedPerson;
|
||||||
@ -89,6 +84,7 @@ export default class CreateEvent extends Vue {
|
|||||||
local: true,
|
local: true,
|
||||||
status: EventStatus.CONFIRMED,
|
status: EventStatus.CONFIRMED,
|
||||||
visibility: EventVisibility.PUBLIC,
|
visibility: EventVisibility.PUBLIC,
|
||||||
|
join_options: EventJoinOptions.FREE,
|
||||||
thumbnail: "",
|
thumbnail: "",
|
||||||
large_image: "",
|
large_image: "",
|
||||||
publish_at: new Date()
|
publish_at: new Date()
|
||||||
|
@ -3,8 +3,13 @@ import EctoEnum
|
|||||||
defenum(Mobilizon.Events.EventVisibilityEnum, :event_visibility_type, [
|
defenum(Mobilizon.Events.EventVisibilityEnum, :event_visibility_type, [
|
||||||
:public,
|
:public,
|
||||||
:unlisted,
|
:unlisted,
|
||||||
:private,
|
:restricted,
|
||||||
:moderated,
|
:private
|
||||||
|
])
|
||||||
|
|
||||||
|
defenum(Mobilizon.Events.JoinOptionsEnum, :event_join_options_type, [
|
||||||
|
:free,
|
||||||
|
:restricted,
|
||||||
:invite
|
:invite
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -33,6 +38,7 @@ defmodule Mobilizon.Events.Event do
|
|||||||
field(:title, :string)
|
field(:title, :string)
|
||||||
field(:status, Mobilizon.Events.EventStatusEnum, default: :confirmed)
|
field(:status, Mobilizon.Events.EventStatusEnum, default: :confirmed)
|
||||||
field(:visibility, Mobilizon.Events.EventVisibilityEnum, default: :public)
|
field(:visibility, Mobilizon.Events.EventVisibilityEnum, default: :public)
|
||||||
|
field(:join_options, Mobilizon.Events.JoinOptionsEnum, default: :free)
|
||||||
field(:thumbnail, :string)
|
field(:thumbnail, :string)
|
||||||
field(:large_image, :string)
|
field(:large_image, :string)
|
||||||
field(:publish_at, Timex.Ecto.DateTimeWithTimezone)
|
field(:publish_at, Timex.Ecto.DateTimeWithTimezone)
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
defmodule Mobilizon.Repo.Migrations.SplitEventVisibilityAndJoinOptions do
|
||||||
|
use Ecto.Migration
|
||||||
|
alias Mobilizon.Events.EventVisibilityEnum
|
||||||
|
alias Mobilizon.Events.JoinOptionsEnum
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
EventVisibilityEnum has dropped some possible values, so we need to recreate it
|
||||||
|
"""
|
||||||
|
def up do
|
||||||
|
execute "ALTER TABLE events ALTER COLUMN visibility TYPE VARCHAR USING visibility::text"
|
||||||
|
EventVisibilityEnum.drop_type
|
||||||
|
EventVisibilityEnum.create_type
|
||||||
|
execute "ALTER TABLE events ALTER COLUMN visibility TYPE event_visibility_type USING visibility::event_visibility_type"
|
||||||
|
|
||||||
|
JoinOptionsEnum.create_type
|
||||||
|
alter table(:events) do
|
||||||
|
add(:join_options, JoinOptionsEnum.type(), null: false, default: "free")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
alter table(:events) do
|
||||||
|
remove(:join_options)
|
||||||
|
end
|
||||||
|
JoinOptionsEnum.drop_type
|
||||||
|
|
||||||
|
execute "ALTER TABLE events ALTER COLUMN visibility TYPE VARCHAR USING visibility::text"
|
||||||
|
EventVisibilityEnum.drop_type
|
||||||
|
EventVisibilityEnum.create_type
|
||||||
|
execute "ALTER TABLE events ALTER COLUMN visibility TYPE event_visibility_type USING visibility::event_visibility_type"
|
||||||
|
end
|
||||||
|
end
|
@ -249,8 +249,7 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do
|
|||||||
test "list_events/3 doesn't list private events", context do
|
test "list_events/3 doesn't list private events", context do
|
||||||
insert(:event, visibility: :private)
|
insert(:event, visibility: :private)
|
||||||
insert(:event, visibility: :unlisted)
|
insert(:event, visibility: :unlisted)
|
||||||
insert(:event, visibility: :moderated)
|
insert(:event, visibility: :restricted)
|
||||||
insert(:event, visibility: :invite)
|
|
||||||
|
|
||||||
query = """
|
query = """
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user