-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(users): updating models and relationships for users. adding dele…
…te account option to user management for admins
- Loading branch information
Showing
12 changed files
with
489 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
enum StripeSubscriptionStatuses { | ||
COMPLETE = 'complete', | ||
ACTIVE = 'active', | ||
PAST_DUE = 'past_due', | ||
UNPAID = 'unpaid', | ||
CANCELED = 'canceled', | ||
INCOMPLETE = 'incomplete', | ||
INCOMPLETE_EXPIRED = 'incomplete_expired', | ||
TRIALING = 'trialing', | ||
PAUSED = 'paused' | ||
} | ||
|
||
export default StripeSubscriptionStatuses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { DateTime } from 'luxon' | ||
import { BelongsTo, belongsTo, column, computed, hasMany, HasMany, manyToMany, ManyToMany } from '@ioc:Adonis/Lucid/Orm' | ||
import AppBaseModel from 'App/Models/AppBaseModel' | ||
import DiscussionViewTypes from 'App/Enums/DiscussionViewTypes' | ||
import User from './User' | ||
import DiscussionView from './DiscussionView' | ||
import Taxonomy from './Taxonomy' | ||
import Comment from './Comment' | ||
|
||
export default class Discussion extends AppBaseModel { | ||
@column({ isPrimary: true }) | ||
declare id: number | ||
|
||
@column() | ||
declare userId: number | ||
|
||
@column() | ||
declare taxonomyId: number | ||
|
||
@column() | ||
declare stateId: number | ||
|
||
@column() | ||
declare title: string | ||
|
||
@column() | ||
declare slug: string | ||
|
||
@column() | ||
declare body: string | ||
|
||
@column.dateTime({ autoCreate: true }) | ||
declare createdAt: DateTime | ||
|
||
@column.dateTime({ autoCreate: true, autoUpdate: true }) | ||
declare updatedAt: DateTime | ||
|
||
@computed() | ||
get createdAtDisplay() { | ||
if (!this.createdAt) return '' | ||
|
||
if (DateTime.now().year === this.createdAt.year) { | ||
return this.createdAt.toFormat('MMM dd') | ||
} | ||
|
||
return this.createdAt.toFormat('MMM dd, yy') | ||
} | ||
|
||
@computed() | ||
get updatedAtDisplay() { | ||
if (!this.updatedAt) return '' | ||
|
||
if (DateTime.now().year === this.updatedAt.year) { | ||
return this.updatedAt.toFormat('MMM dd') | ||
} | ||
|
||
return this.updatedAt.toFormat('MMM dd, yy') | ||
} | ||
|
||
@belongsTo(() => User) | ||
declare user: BelongsTo<typeof User> | ||
|
||
@belongsTo(() => Taxonomy) | ||
declare taxonomy: BelongsTo<typeof Taxonomy> | ||
|
||
@hasMany(() => Comment) | ||
declare comments: HasMany<typeof Comment> | ||
|
||
@hasMany(() => DiscussionView, { | ||
onQuery(query) { | ||
query.where('typeId', DiscussionViewTypes.VIEW) | ||
} | ||
}) | ||
declare views: HasMany<typeof DiscussionView> | ||
|
||
@hasMany(() => DiscussionView) | ||
declare impressions: HasMany<typeof DiscussionView> | ||
|
||
@manyToMany(() => User, { | ||
pivotTable: 'discussion_votes' | ||
}) | ||
declare votes: ManyToMany<typeof User> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { DateTime } from 'luxon' | ||
import { BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm' | ||
import AppBaseModel from 'App/Models/AppBaseModel' | ||
import DiscussionViewTypes from 'App/Enums/DiscussionViewTypes' | ||
import User from './User' | ||
import Discussion from './Discussion' | ||
|
||
export default class DiscussionView extends AppBaseModel { | ||
@column({ isPrimary: true }) | ||
declare id: number | ||
|
||
@column() | ||
declare userId: number | null | ||
|
||
@column() | ||
declare discussionId: number | ||
|
||
@column() | ||
declare typeId: DiscussionViewTypes | ||
|
||
@column() | ||
declare ipAddress: string | ||
|
||
@column() | ||
declare userAgent: string | ||
|
||
@column.dateTime({ autoCreate: true }) | ||
declare createdAt: DateTime | ||
|
||
@column.dateTime({ autoCreate: true, autoUpdate: true }) | ||
declare updatedAt: DateTime | ||
|
||
@belongsTo(() => User) | ||
declare user: BelongsTo<typeof User> | ||
|
||
@belongsTo(() => Discussion) | ||
declare discussion: BelongsTo<typeof Discussion> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { BaseModel, column, belongsTo, BelongsTo } from "@ioc:Adonis/Lucid/Orm" | ||
import { DateTime } from "luxon" | ||
import Discussion from "./Discussion" | ||
import User from "./User" | ||
|
||
export default class DiscussionVote extends BaseModel { | ||
@column({ isPrimary: true }) | ||
declare id: number | ||
|
||
@column() | ||
declare userId: number | null | ||
|
||
@column() | ||
declare discussionId: number | null | ||
|
||
@column.dateTime({ autoCreate: true }) | ||
declare createdAt: DateTime | ||
|
||
@column.dateTime({ autoCreate: true, autoUpdate: true }) | ||
declare updatedAt: DateTime | ||
|
||
@belongsTo(() => User) | ||
declare user: BelongsTo<typeof User> | ||
|
||
@belongsTo(() => Discussion) | ||
declare discussion: BelongsTo<typeof Discussion> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { DateTime } from 'luxon' | ||
import { BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm' | ||
import AppBaseModel from 'App/Models/AppBaseModel' | ||
import Post from 'App/Models/Post' | ||
import Collection from 'App/Models/Collection' | ||
|
||
export default class Progress extends AppBaseModel { | ||
@column({ isPrimary: true }) | ||
declare id: number | ||
|
||
@column() | ||
declare userId: number | ||
|
||
@column() | ||
declare postId: number | null | ||
|
||
@column() | ||
declare collectionId: number | null | ||
|
||
@column() | ||
declare readPercent: number | null | ||
|
||
@column() | ||
declare watchPercent: number | null | ||
|
||
@column() | ||
declare watchSeconds: number | ||
|
||
@column() | ||
declare isCompleted: boolean | ||
|
||
@column.dateTime({ autoCreate: true }) | ||
declare createdAt: DateTime | ||
|
||
@column.dateTime({ autoCreate: true, autoUpdate: true }) | ||
declare updatedAt: DateTime | ||
|
||
@belongsTo(() => Post) | ||
declare post: BelongsTo<typeof Post> | ||
|
||
@belongsTo(() => Collection) | ||
declare collection: BelongsTo<typeof Collection> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { DateTime } from 'luxon' | ||
import { BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm' | ||
import AppBaseModel from 'App/Models/AppBaseModel' | ||
import User from './User' | ||
|
||
export default class SessionLog extends AppBaseModel { | ||
@column({ isPrimary: true }) | ||
declare id: number | ||
|
||
@column() | ||
declare userId: number | ||
|
||
@column() | ||
declare token: string | ||
|
||
@column() | ||
declare ipAddress: string | null | ||
|
||
@column() | ||
declare userAgent: string | null | ||
|
||
@column() | ||
declare browserName: string | null | ||
|
||
@column() | ||
declare browserEngine: string | null | ||
|
||
@column() | ||
declare browserVersion: string | null | ||
|
||
@column() | ||
declare deviceModel: string | null | ||
|
||
@column() | ||
declare deviceType: string | null | ||
|
||
@column() | ||
declare deviceVendor: string | null | ||
|
||
@column() | ||
declare osName: string | null | ||
|
||
@column() | ||
declare osVersion: string | null | ||
|
||
@column() | ||
declare city: string | null | ||
|
||
@column() | ||
declare country: string | null | ||
|
||
@column() | ||
declare countryCode: string | null | ||
|
||
@column.dateTime() | ||
declare lastTouchedAt: DateTime | null | ||
|
||
@column.dateTime() | ||
declare loginAt: DateTime | null | ||
|
||
@column() | ||
declare loginSuccessful: boolean | ||
|
||
@column.dateTime() | ||
declare logoutAt: DateTime | null | ||
|
||
@column() | ||
declare forceLogout: boolean | ||
|
||
@column() | ||
declare isRememberSession: boolean | ||
|
||
@column.dateTime({ autoCreate: true }) | ||
declare createdAt: DateTime | ||
|
||
@column.dateTime({ autoCreate: true, autoUpdate: true }) | ||
declare updatedAt: DateTime | ||
|
||
@belongsTo(() => User) | ||
declare user: BelongsTo<typeof User> | ||
|
||
isCurrentSession: boolean = false | ||
} |
Oops, something went wrong.