From c2a421eabd5f2d8dace8b47dc1f840907b63d703 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 22 Feb 2019 16:54:01 +0100 Subject: [PATCH 1/2] Make Categories a predefined list Signed-off-by: Thomas Citharel Allow null values for categories for now Signed-off-by: Thomas Citharel --- js/src/App.vue | 6 - js/src/graphql/category.ts | 29 ----- js/src/graphql/event.ts | 14 +-- js/src/router/category.ts | 22 ---- js/src/router/index.ts | 3 - js/src/types/event.model.ts | 12 +- js/src/views/Category/Create.vue | 75 ------------ js/src/views/Category/List.vue | 55 --------- js/src/views/Event/Create.vue | 33 +++--- js/src/views/Event/Event.vue | 2 +- lib/mobilizon/events/category.ex | 26 ----- lib/mobilizon/events/event.ex | 16 ++- lib/mobilizon/events/events.ex | 109 ------------------ lib/mobilizon_web/resolvers/category.ex | 48 -------- lib/mobilizon_web/schema.ex | 2 - lib/mobilizon_web/schema/event.ex | 3 +- lib/mobilizon_web/schema/events/category.ex | 34 ------ .../uploaders/{category.ex => event.ex} | 3 +- .../views/activity_pub/object_view.ex | 14 +-- lib/service/activity_pub/activity_pub.ex | 22 +--- lib/service/activity_pub/utils.ex | 2 +- .../20190222151449_drop_categories.exs | 35 ++++++ test/mobilizon/events/events_test.exs | 76 +----------- .../resolvers/category_resolver_test.exs | 77 ------------- .../resolvers/event_resolver_test.exs | 10 +- .../resolvers/participant_resolver_test.exs | 7 +- test/support/factory.ex | 9 +- 27 files changed, 89 insertions(+), 655 deletions(-) delete mode 100644 js/src/graphql/category.ts delete mode 100644 js/src/router/category.ts delete mode 100644 js/src/views/Category/Create.vue delete mode 100644 js/src/views/Category/List.vue delete mode 100644 lib/mobilizon/events/category.ex delete mode 100644 lib/mobilizon_web/resolvers/category.ex delete mode 100644 lib/mobilizon_web/schema/events/category.ex rename lib/mobilizon_web/uploaders/{category.ex => event.ex} (91%) create mode 100644 priv/repo/migrations/20190222151449_drop_categories.exs delete mode 100644 test/mobilizon_web/resolvers/category_resolver_test.exs diff --git a/js/src/App.vue b/js/src/App.vue index ac3070a21..79b809b51 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -49,12 +49,6 @@ export default class App extends Vue { route: "GroupList", role: null }, - { - icon: "content_copy", - text: "Categories", - route: "CategoryList", - role: "ROLE_ADMIN" - }, { icon: "settings", text: "Settings", role: "ROLE_USER" }, { icon: "chat_bubble", text: "Send feedback", role: "ROLE_USER" }, { icon: "help", text: "Help", role: null }, diff --git a/js/src/graphql/category.ts b/js/src/graphql/category.ts deleted file mode 100644 index 3966ff137..000000000 --- a/js/src/graphql/category.ts +++ /dev/null @@ -1,29 +0,0 @@ -import gql from 'graphql-tag'; - -export const FETCH_CATEGORIES = gql` -query { - categories { - id, - title, - description, - picture { - url, - }, - } -} -`; - -export const CREATE_CATEGORY = gql` - mutation createCategory($title: String!, $description: String!, $picture: Upload!) { - createCategory(title: $title, description: $description, picture: $picture) { - id, - title, - description, - picture { - url, - url_thumbnail - }, - }, - }, - -`; diff --git a/js/src/graphql/event.ts b/js/src/graphql/event.ts index b5989eeb0..75f908934 100644 --- a/js/src/graphql/event.ts +++ b/js/src/graphql/event.ts @@ -25,6 +25,7 @@ export const FETCH_EVENT = gql` thumbnail, large_image, publish_at, + category, # online_address, # phone_address, organizerActor { @@ -39,10 +40,7 @@ export const FETCH_EVENT = gql` # }, participants { ${participantQuery} - }, - category { - title, - }, + } } } `; @@ -75,9 +73,7 @@ export const FETCH_EVENTS = gql` preferredUsername, name, }, - category { - title, - }, + category, participants { ${participantQuery} } @@ -112,9 +108,9 @@ export const EDIT_EVENT = gql` $title: String!, $description: String!, $organizerActorId: Int!, - $categoryId: Int! + $category: String! ) { - EditEvent(title: $title, description: $description, organizerActorId: $organizerActorId, categoryId: $categoryId) { + EditEvent(title: $title, description: $description, organizerActorId: $organizerActorId, category: $category) { uuid } } diff --git a/js/src/router/category.ts b/js/src/router/category.ts deleted file mode 100644 index 1dee45401..000000000 --- a/js/src/router/category.ts +++ /dev/null @@ -1,22 +0,0 @@ -import CategoryList from '@/views/Category/List.vue'; -import CreateCategory from '@/views/Category/Create.vue'; - -export enum CategoryRouteName { - CATEGORY_LIST = 'CategoryList', - CREATE_CATEGORY = 'CreateCategory', -} - -export const categoryRoutes = [ - { - path: '/category', - name: CategoryRouteName.CATEGORY_LIST, - component: CategoryList, - meta: { requiredAuth: false }, - }, - { - path: '/category/create', - name: CategoryRouteName.CREATE_CATEGORY, - component: CreateCategory, - meta: { requiredAuth: true }, - }, -]; diff --git a/js/src/router/index.ts b/js/src/router/index.ts index aa259fcd4..0663b53d4 100644 --- a/js/src/router/index.ts +++ b/js/src/router/index.ts @@ -5,7 +5,6 @@ import Home from '@/views/Home.vue'; import { UserRouteName, userRoutes } from './user'; import { EventRouteName, eventRoutes } from '@/router/event'; import { ActorRouteName, actorRoutes } from '@/router/actor'; -import { CategoryRouteName, categoryRoutes } from '@/router/category'; Vue.use(Router); @@ -20,7 +19,6 @@ export const RouteName = { ...GlobalRouteName, ...UserRouteName, ...EventRouteName, - ...CategoryRouteName, ...ActorRouteName, }; @@ -30,7 +28,6 @@ const router = new Router({ routes: [ ...userRoutes, ...eventRoutes, - ...categoryRoutes, ...actorRoutes, { diff --git a/js/src/types/event.model.ts b/js/src/types/event.model.ts index 48c713d13..42893dec8 100644 --- a/js/src/types/event.model.ts +++ b/js/src/types/event.model.ts @@ -27,10 +27,12 @@ export enum ParticipantRole { CREATOR = 'creator', } -export interface ICategory { - title: string; - description: string; - picture: string; +export enum Category { + BUSINESS = 'business', + CONFERENCE = 'conference', + BIRTHDAY = 'birthday', + DEMONSTRATION = 'demonstration', + MEETING = 'meeting', } export interface IParticipant { @@ -47,7 +49,7 @@ export interface IEvent { title: string; description: string; - category: ICategory; + category: Category; begins_on: Date; ends_on: Date; diff --git a/js/src/views/Category/Create.vue b/js/src/views/Category/Create.vue deleted file mode 100644 index 6617bb72d..000000000 --- a/js/src/views/Category/Create.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - diff --git a/js/src/views/Category/List.vue b/js/src/views/Category/List.vue deleted file mode 100644 index 0fb1a6e70..000000000 --- a/js/src/views/Category/List.vue +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - diff --git a/js/src/views/Event/Create.vue b/js/src/views/Event/Create.vue index b674f9f66..60e8e55b0 100644 --- a/js/src/views/Event/Create.vue +++ b/js/src/views/Event/Create.vue @@ -1,3 +1,4 @@ +import {Category} from "../../types/event.model"; import {EventJoinOptions} from "../../types/event.model";