Skip to content

Commit 0e3ecb5

Browse files
committed
feat: add event creation form page
1 parent 8e3bf91 commit 0e3ecb5

31 files changed

+415
-108
lines changed

public/locales/en/affix.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2-
"affixButtonTitle": "Click here to add a claim or a personality",
3-
"affixButtonCreateClaim": "Click here to add a claim",
4-
"affixButtonCreatePersonality": "Click here to add a personality",
5-
"affixButtonCreateVerifiedSources": "Click here to add a source",
6-
"affixButtonCreateVerificationRequest": "Click here to add a verification request",
7-
"affixCallToActionButton": "Click here",
8-
"AffixCloseTooltip": "Close",
9-
"affixCopilotTitle": "Click here to open the Aletheia's Assistant"
2+
"affixButtonTitle": "Click here to add a claim or a personality",
3+
"affixButtonCreateClaim": "Click here to add a claim",
4+
"affixButtonCreatePersonality": "Click here to add a personality",
5+
"affixButtonCreateVerifiedSources": "Click here to add a source",
6+
"affixButtonCreateVerificationRequest": "Click here to add a verification request",
7+
"affixButtonCreateEvent": "Click here to add a event",
8+
"affixCallToActionButton": "Click here",
9+
"AffixCloseTooltip": "Close",
10+
"affixCopilotTitle": "Click here to open the Aletheia's Assistant"
1011
}

public/locales/en/events.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"eventCreateSuccess": "Event created successfully",
23
"totalItems": "{{total}} in total",
34
"openEvent": "See event",
45
"fetchError": "Error fetching events. Please try again later.",
@@ -7,5 +8,21 @@
78
"filterAll": "All",
89
"filterOngoing": "Ongoing",
910
"filterUpcoming": "Upcoming",
10-
"filterFinished": "Finished"
11+
"filterFinished": "Finished",
12+
"badgeLabel": "Badge",
13+
"badgePlaceholder": "Enter badge",
14+
"nameLabel": "Name",
15+
"namePlaceholder": "Enter event name",
16+
"descriptionLabel": "Description",
17+
"descriptionPlaceholder": "Describe the event",
18+
"locationLabel": "Location",
19+
"locationPlaceholder": "Enter event location",
20+
"startDateLabel": "Start date",
21+
"startDatePlaceholder": "Select start date",
22+
"endDateLabel": "End date",
23+
"endDatePlaceholder": "Select end date",
24+
"mainTopicLabel": "Main topic",
25+
"mainTopicPlaceholder": "Search and select the main topic",
26+
"filterTopicsLabel": "Filter topics",
27+
"filterTopicsPlaceholder": "Search and select filter topics"
1128
}

public/locales/en/seo.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
"verificationRequestTitle": "Verification Requests",
1818
"verificationRequestDescription": "See verification requests on AletheiaFact.org",
1919
"createVerificationRequestTitle": "Create verification request",
20-
"createVerificationRequestDescription": "Create verification requests to AletheiaFact.org"
20+
"createVerificationRequestDescription": "Create verification requests to AletheiaFact.org",
21+
"createEventTitle": "Create event",
22+
"createEventDescription": "Create event to AletheiaFact.org"
2123
}

public/locales/pt/affix.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2-
"affixButtonTitle": "Clique aqui para adicionar uma afirmação ou personalidade",
3-
"affixButtonCreateClaim": "Clique aqui para adicionar uma afirmação",
4-
"affixButtonCreatePersonality": "Clique aqui para adicionar uma personalidade",
5-
"affixButtonCreateVerifiedSources": "Clique aqui para adicionar uma informação checada",
6-
"affixButtonCreateVerificationRequest": "Clique aqui para adicionar uma denúncia",
7-
"affixCallToActionButton": "Clique aqui",
8-
"AffixCloseTooltip": "Fechar",
9-
"affixCopilotTitle": "Clique aqui para abrir o Assistente Aletheia"
2+
"affixButtonTitle": "Clique aqui para adicionar uma afirmação ou personalidade",
3+
"affixButtonCreateClaim": "Clique aqui para adicionar uma afirmação",
4+
"affixButtonCreatePersonality": "Clique aqui para adicionar uma personalidade",
5+
"affixButtonCreateVerifiedSources": "Clique aqui para adicionar uma informação checada",
6+
"affixButtonCreateVerificationRequest": "Clique aqui para adicionar uma denúncia",
7+
"affixButtonCreateEvent": "Clique aqui para adicionar um evento",
8+
"affixCallToActionButton": "Clique aqui",
9+
"AffixCloseTooltip": "Fechar",
10+
"affixCopilotTitle": "Clique aqui para abrir o Assistente Aletheia"
1011
}

public/locales/pt/events.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"eventCreateSuccess": "Evento criado com sucesso",
23
"totalItems": "{{total}} no total",
34
"openEvent": "Veja evento",
45
"fetchError": "Erro ao carregar eventos. Por favor, tente novamente mais tarde.",
@@ -7,5 +8,21 @@
78
"filterAll": "Todos",
89
"filterHappening": "Agora",
910
"filterUpcoming": "Em breve",
10-
"filterFinished": "Encerrados"
11+
"filterFinished": "Encerrados",
12+
"badgeLabel": "Badge",
13+
"badgePlaceholder": "Digite o badge",
14+
"nameLabel": "Nome",
15+
"namePlaceholder": "Digite o nome do evento",
16+
"descriptionLabel": "Descrição",
17+
"descriptionPlaceholder": "Descreva o evento",
18+
"locationLabel": "Local",
19+
"locationPlaceholder": "Digite o local do evento",
20+
"startDateLabel": "Data de início",
21+
"startDatePlaceholder": "Selecione a data de início",
22+
"endDateLabel": "Data de término",
23+
"endDatePlaceholder": "Selecione a data de término",
24+
"mainTopicLabel": "Tópico principal",
25+
"mainTopicPlaceholder": "Busque e selecione o tópico principal",
26+
"filterTopicsLabel": "Tópicos de filtro",
27+
"filterTopicsPlaceholder": "Busque e selecione tópicos de filtro"
1128
}

public/locales/pt/seo.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
"verificationRequestTitle": "Denúncias",
1818
"verificationRequestDescription": "Veja as denúncias na AletheiaFact.org",
1919
"createVerificationRequestTitle": "Adicione uma denuncia",
20-
"createVerificationRequestDescription": "Adiciona uma denúncia na AletheiaFact.org"
20+
"createVerificationRequestDescription": "Adiciona uma denúncia na AletheiaFact.org",
21+
"createEventTitle": "Adicione um evento",
22+
"createEventDescription": "Adicione um na AletheiaFact.org"
2123
}

server/events/dto/event.dto.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { Type } from "class-transformer";
1111
import type { TopicData } from "../../topic/types/topic.interfaces";
1212

1313
export class CreateEventDTO {
14+
@IsString()
15+
@IsOptional()
16+
@ApiProperty()
17+
nameSpace?: string;
18+
1419
@IsString()
1520
@IsNotEmpty()
1621
@ApiProperty()
@@ -48,10 +53,15 @@ export class CreateEventDTO {
4853
@ApiProperty()
4954
mainTopic: TopicData;
5055

56+
@IsString()
57+
@IsOptional()
58+
@ApiProperty()
59+
recaptcha?: string;
60+
}
61+
62+
export class UpdateEventDTO extends PartialType(CreateEventDTO) {
5163
@IsArray()
5264
@IsOptional()
5365
@ApiProperty()
5466
filterTopics: TopicData[];
5567
}
56-
57-
export class UpdateEventDTO extends PartialType(CreateEventDTO) { }

server/events/event.controller.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,27 @@ export class EventsController {
8282
);
8383
}
8484

85+
@FactCheckerOnly()
86+
@ApiTags("pages")
87+
@Get("event/create")
88+
public async createEventPage(
89+
@Req() req: BaseRequest,
90+
@Res() res: Response
91+
) {
92+
const parsedUrl = parse(req.url, true);
93+
const queryObject = Object.assign(parsedUrl.query, {
94+
sitekey: this.configService.get<string>("recaptcha_sitekey"),
95+
nameSpace: req.params.namespace,
96+
});
97+
98+
await this.viewService.render(
99+
req,
100+
res,
101+
"/event-create",
102+
queryObject
103+
);
104+
}
105+
85106
@Public()
86107
@ApiTags("pages")
87108
@Get("event/:data_hash")

server/events/event.service.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,10 @@ export class EventsService {
3737
try {
3838
this.logger.debug("Creating event", { createEventDto });
3939

40-
const allTopics = [
41-
createEventDto.mainTopic,
42-
...(createEventDto.filterTopics) || []
43-
];
44-
45-
const createdTopics = await Promise.all(
46-
allTopics.map(topicData =>
47-
this.topicService.findOrCreateTopic(topicData)
48-
)
49-
);
50-
51-
const [mainTopic, ...filterTopics] = createdTopics;
40+
const createdTopic = await this.topicService.findOrCreateTopic({
41+
...createEventDto.mainTopic,
42+
name: createEventDto.mainTopic.label
43+
})
5244

5345
const data_hash = crypto
5446
.createHash("md5")
@@ -58,8 +50,7 @@ export class EventsService {
5850
const newEvent = await this.eventModel.create({
5951
...createEventDto,
6052
data_hash,
61-
mainTopic,
62-
filterTopics
53+
mainTopic: createdTopic._id
6354
})
6455

6556
this.logger.log(`Event created successfully: ${newEvent._id}`);

server/topic/topic.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export class TopicService {
218218
* @param topicData object with { slug?, name, wikidataId?, language?, description? }
219219
* @returns the existing or newly created topic document
220220
*/
221-
async findOrCreateTopic(topicData: TopicData): Promise<Topic> {
221+
async findOrCreateTopic(topicData: TopicData): Promise<TopicDocument> {
222222
try {
223223
const slug = slugify(topicData.name, { lower: true, strict: true });
224224

0 commit comments

Comments
 (0)