This repository has been archived by the owner on Feb 10, 2025. It is now read-only.
-
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.
- Loading branch information
Showing
31 changed files
with
485 additions
and
252 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext' | ||
import Collection from 'App/Models/Collection' | ||
import Post from 'App/Models/Post' | ||
import Taxonomy from 'App/Models/Taxonomy' | ||
|
||
export default class DashboardController { | ||
public async index({ view }: HttpContextContract) { | ||
return view.render('studio/index') | ||
const postCount = await Post.query().apply(s => s.published()).getCount() | ||
const postSeconds = await Post.query().sum('video_seconds').first() | ||
const seriesCount = await Collection.series().wherePublic().getCount() | ||
const topicCount = await Taxonomy.query().getCount() | ||
|
||
return view.render('studio/index', { postCount, postSeconds, seriesCount, topicCount }) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
enum Role { | ||
USER = 1, | ||
ADMIN = 2 | ||
ADMIN = 2, | ||
CONTRIBUTOR = 3 | ||
} | ||
|
||
export default Role; |
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,40 @@ | ||
import BasePolicy from './BasePolicy' | ||
import User from 'App/Models/User' | ||
import Collection from 'App/Models/Collection' | ||
|
||
export default class CollectionPolicy extends BasePolicy { | ||
public async before(user: User) { | ||
if (this.isAdmin(user)) { | ||
return true | ||
} | ||
} | ||
|
||
public async viewList(user: User) { | ||
return this.canContribute(user) | ||
} | ||
|
||
public async view(user: User, _collection: Collection) { | ||
return this.canContribute(user) | ||
} | ||
|
||
public async feature(_user: User) { | ||
return false | ||
} | ||
|
||
public async create(user: User) { | ||
return this.canContribute(user) | ||
} | ||
|
||
public async update(user: User, _collection: Collection) { | ||
return this.canContribute(user) | ||
} | ||
|
||
public async delete(user: User, collection: Collection) { | ||
return this.isOwner(user, collection) | ||
} | ||
|
||
public async isOwner(user: User, collection: Collection) { | ||
if (!collection) return this.canContribute(user) | ||
return collection.ownerId === user.id | ||
} | ||
} |
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
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
Oops, something went wrong.