Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
chore(revert): readd the filters for reconstruction
Browse files Browse the repository at this point in the history
This reverts commit 62415d8.
This reverts commit 8605dce.
This reverts commit 6c04053.
This reverts commit 9b36ca3.
This reverts commit 4da4c88.
This reverts commit b1c30d3.
This reverts commit 993d9bf.
This reverts commit 98fde69.
  • Loading branch information
KennethTrecy committed Nov 22, 2022
1 parent 5c6dd97 commit 1641bb9
Show file tree
Hide file tree
Showing 65 changed files with 1,711 additions and 10 deletions.
30 changes: 30 additions & 0 deletions common_front-end/fetchers/profanity_filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type {
ProfanityFilterResourceIdentifier,
ProfanityFilterAttributes,
ProfanityFilterResource,
DeserializedProfanityFilterResource,
ProfanityFilterDocument,
ProfanityFilterListDocument,
DeserializedProfanityFilterDocument,
DeserializedProfanityFilterListDocument
} from "$/types/documents/profanity_filter"

import { PROFANITY_FILTER_LINK } from "$/constants/template_links"

import BaseFetcher from "$@/fetchers/base"

export default class ProfanityFilterFetcher extends BaseFetcher<
ProfanityFilterResourceIdentifier<"read">,
ProfanityFilterAttributes<"serialized">,
ProfanityFilterAttributes<"deserialized">,
ProfanityFilterResource,
DeserializedProfanityFilterResource,
ProfanityFilterDocument,
ProfanityFilterListDocument,
DeserializedProfanityFilterDocument,
DeserializedProfanityFilterListDocument
> {
constructor() {
super(PROFANITY_FILTER_LINK)
}
}
9 changes: 9 additions & 0 deletions common_front-end/helpers/filter_link_infos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ describe("Helper: Filter Link Infos", () => {
"id": "2",
"name": "B",
"postFlags": 0,
"profanityFlags": 0,
"roleFlags": 0,
"semesterFlags": 0,
"tagFlags": 0,
Expand Down Expand Up @@ -178,6 +179,7 @@ describe("Helper: Filter Link Infos", () => {
"id": "2",
"name": "B",
"postFlags": 0,
"profanityFlags": 0,
"roleFlags": 0,
"semesterFlags": 0,
"tagFlags": 0,
Expand Down Expand Up @@ -246,6 +248,7 @@ describe("Helper: Filter Link Infos", () => {
"id": "2",
"name": "B",
"postFlags": 0,
"profanityFlags": 0,
"roleFlags": 0,
"semesterFlags": 0,
"tagFlags": 0,
Expand Down Expand Up @@ -348,6 +351,7 @@ describe("Helper: Filter Link Infos", () => {
"id": "2",
"name": "B",
"postFlags": 0,
"profanityFlags": 0,
"roleFlags": 0,
"semesterFlags": 0,
"tagFlags": 0,
Expand Down Expand Up @@ -422,6 +426,7 @@ describe("Helper: Filter Link Infos", () => {
"id": "2",
"name": "B",
"postFlags": 0,
"profanityFlags": 0,
"roleFlags": 0,
"semesterFlags": 0,
"tagFlags": 0,
Expand Down Expand Up @@ -490,6 +495,7 @@ describe("Helper: Filter Link Infos", () => {
"id": "2",
"name": "B",
"postFlags": 0,
"profanityFlags": 0,
"roleFlags": 0,
"semesterFlags": 0,
"tagFlags": 0,
Expand Down Expand Up @@ -610,6 +616,7 @@ describe("Helper: Filter Link Infos", () => {
"id": "2",
"name": "B",
"postFlags": 0,
"profanityFlags": 0,
"roleFlags": 0,
"semesterFlags": 0,
"tagFlags": 0,
Expand Down Expand Up @@ -685,6 +692,7 @@ describe("Helper: Filter Link Infos", () => {
"id": "2",
"name": "B",
"postFlags": 0,
"profanityFlags": 0,
"roleFlags": 0,
"semesterFlags": 0,
"tagFlags": 0,
Expand Down Expand Up @@ -783,6 +791,7 @@ describe("Helper: Filter Link Infos", () => {
"id": "2",
"name": "B",
"postFlags": 0,
"profanityFlags": 0,
"roleFlags": 0,
"semesterFlags": 0,
"tagFlags": 0,
Expand Down
4 changes: 2 additions & 2 deletions components/post/multiviewer/viewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Component from "./viewer.vue"

jest.useFakeTimers()
describe("Component: post/viewer", () => {
it.skip("should submit post errors", async() => {
it("should submit post errors", async() => {
const userID = "1"
const postID = "2"
const roleID = "3"
Expand Down Expand Up @@ -127,7 +127,7 @@ describe("Component: post/viewer", () => {
expect(updateEvent).toHaveProperty("0.0", modelValue)
})

it.skip("should request for archiving the post", async() => {
it("should request for archiving the post", async() => {
const userID = "1"
const postID = "2"
const roleID = "3"
Expand Down
3 changes: 3 additions & 0 deletions components/role/make_flag_selector_infos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
tag as tagPermissions,
post as postPermissions,
comment as commentPermissions,
profanity as profanityPermissions,
user as userPermissions,
auditTrail as auditTrailPermissions
} from "$/permissions/permission_list"
Expand Down Expand Up @@ -74,6 +75,7 @@ export default function(role: Ref<RoleAttributes<"deserialized">>): FlagSelector
tagPermissions,
postPermissions,
commentPermissions,
profanityPermissions,
userPermissions,
auditTrailPermissions
].filter(info => !unsuspectedNames.includes(info.name))
Expand Down Expand Up @@ -126,6 +128,7 @@ export default function(role: Ref<RoleAttributes<"deserialized">>): FlagSelector
makeFlagSelectorInfo("Comment", commentPermissions, {
"checkExternal": checkExternalDependencies
}),
makeFlagSelectorInfo("Profanity", profanityPermissions),
makeFlagSelectorInfo("User", userPermissions),
makeFlagSelectorInfo("Audit Trail", auditTrailPermissions)
]
Expand Down
2 changes: 2 additions & 0 deletions database/data_source/create_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import StudentDetail from "%/models/student_detail"
import FoundPostWord from "%/models/found_post_word"
import ProfilePicture from "%/models/profile_picture"
import PostAttachment from "%/models/post_attachment"
import ProfanityFilter from "%/models/profanity_filter"
import createConfiguration from "%/configuration/create"
import EmployeeSchedule from "%/models/employee_schedule"
import AsynchronousFile from "%/models/asynchronous_file"
Expand Down Expand Up @@ -49,6 +50,7 @@ export default async function(type: SourceType): Promise<Sequelize> {
FoundPostWord,
ProfilePicture,
PostAttachment,
ProfanityFilter,
EmployeeSchedule,
AsynchronousFile,
FoundCommentWord,
Expand Down
26 changes: 26 additions & 0 deletions database/managers/found_comment_word.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Factory from "~/factories/found_comment_word"
import Manager from "./found_comment_word"

describe("Database Manager: Post profanity filter read operations", () => {
it("can check if model belongs to comment", async() => {
const manager = new Manager()
const model = await new Factory().insertOne()

const foundModel = await manager.findFoundCommentWord(
model.commentID, model.profanityFilterID)

expect(foundModel).not.toBeNull()
expect(foundModel).toHaveProperty("id", model.id)
})
})

describe("Database Manager: Miscellaneous comment profanity filter operations", () => {
it("can get sortable columns", () => {
// Include in test to alert in case there are new columns to decide whether to expose or not
const manager = new Manager()

const { sortableColumns } = manager

expect(sortableColumns).toStrictEqual([])
})
})
40 changes: 40 additions & 0 deletions database/managers/found_comment_word.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { CommonQueryParameters } from "$/types/query"
import type { FoundCommentWordAttributes } from "$/types/documents/found_comment_word"
import type {
ModelCtor
} from "%/types/dependent"

import Model from "%/models/found_comment_word"
import BaseManager from "%/managers/base"
import Condition from "%/helpers/condition"
import Transformer from "%/transformers/found_comment_word"

export default class extends BaseManager<
Model,
FoundCommentWordAttributes<"deserialized">,
CommonQueryParameters
> {
get model(): ModelCtor<Model> { return Model }

get transformer(): Transformer { return new Transformer() }

get exposableColumns(): string[] {
return []
}

async findFoundCommentWord(commentID: number, profanityFilterID: number): Promise<Model|null> {
try {
const attachedRole = await Model.findOne({
"where": new Condition().and(
new Condition().equal("commentID", commentID),
new Condition().equal("profanityFilterID", profanityFilterID)
).build(),
...this.transaction.transactionObject
})

return attachedRole
} catch (error) {
throw this.makeBaseError(error)
}
}
}
25 changes: 25 additions & 0 deletions database/managers/found_post_word.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Factory from "~/factories/found_post_word"
import Manager from "./found_post_word"

describe("Database Manager: Post profanity filter read operations", () => {
it("can check if model belongs to post", async() => {
const manager = new Manager()
const model = await new Factory().insertOne()

const foundModel = await manager.findFoundPostWord(model.postID, model.profanityFilterID)

expect(foundModel).not.toBeNull()
expect(foundModel).toHaveProperty("id", model.id)
})
})

describe("Database Manager: Miscellaneous post profanity filter operations", () => {
it("can get sortable columns", () => {
// Include in test to alert in case there are new columns to decide whether to expose or not
const manager = new Manager()

const { sortableColumns } = manager

expect(sortableColumns).toStrictEqual([])
})
})
40 changes: 40 additions & 0 deletions database/managers/found_post_word.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { CommonQueryParameters } from "$/types/query"
import type { FoundPostWordAttributes } from "$/types/documents/found_post_word"
import type {
ModelCtor
} from "%/types/dependent"

import Model from "%/models/found_post_word"
import BaseManager from "%/managers/base"
import Condition from "%/helpers/condition"
import Transformer from "%/transformers/found_post_word"

export default class extends BaseManager<
Model,
FoundPostWordAttributes<"deserialized">,
CommonQueryParameters
> {
get model(): ModelCtor<Model> { return Model }

get transformer(): Transformer { return new Transformer() }

get exposableColumns(): string[] {
return []
}

async findFoundPostWord(postID: number, profanityFilterID: number): Promise<Model|null> {
try {
const attachedRole = await Model.findOne({
"where": new Condition().and(
new Condition().equal("postID", postID),
new Condition().equal("profanityFilterID", profanityFilterID)
).build(),
...this.transaction.transactionObject
})

return attachedRole
} catch (error) {
throw this.makeBaseError(error)
}
}
}
23 changes: 23 additions & 0 deletions database/managers/profanity_filter.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Manager from "./profanity_filter"

describe("Database Manager: Miscellaneous semester operations", () => {
it("can get sortable columns", () => {
// Include in test to alert in case there are new columns to decide whether to expose or not
const manager = new Manager()

const { sortableColumns } = manager

expect(sortableColumns).toStrictEqual([
"-createdAt",
"-deletedAt",
"-id",
"-updatedAt",
"-word",
"createdAt",
"deletedAt",
"id",
"updatedAt",
"word"
])
})
})
18 changes: 18 additions & 0 deletions database/managers/profanity_filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { CommonQueryParameters } from "$/types/query"
import type { ModelCtor } from "%/types/dependent"
import type { ProfanityFilterAttributes } from "$/types/documents/profanity_filter"

import BaseManager from "%/managers/base"
import ProfanityFilter from "%/models/profanity_filter"

import ProfanityFilterTransformer from "%/transformers/profanity_filter"

export default class extends BaseManager<
ProfanityFilter,
ProfanityFilterAttributes<"deserialized">,
CommonQueryParameters
> {
get model(): ModelCtor<ProfanityFilter> { return ProfanityFilter }

get transformer(): ProfanityFilterTransformer { return new ProfanityFilterTransformer() }
}
34 changes: 34 additions & 0 deletions database/models/found_comment_word.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {
Model,
Table,
Column,
BelongsTo,
ForeignKey
} from "sequelize-typescript"

import ProfanityFilter from "%/models/profanity_filter"
import Comment from "%/models/comment"

@Table({
"paranoid": true,
"timestamps": true
})
export default class FoundCommentWord extends Model {
@ForeignKey(() => Comment)
@Column({
"allowNull": false
})
commentID!: number

@BelongsTo(() => Comment)
comment!: Comment

@ForeignKey(() => ProfanityFilter)
@Column({
"allowNull": false
})
profanityFilterID!: number

@BelongsTo(() => ProfanityFilter)
profanityFilter!: ProfanityFilter
}
Loading

0 comments on commit 1641bb9

Please sign in to comment.