Skip to content

Commit

Permalink
Added commentators feature
Browse files Browse the repository at this point in the history
  • Loading branch information
CBenni committed Dec 6, 2020
1 parent d977769 commit d9389ef
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
6 changes: 3 additions & 3 deletions backend/src/api/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { sendNotification } from '../notifications';
export async function getUserSubmissions(req, res) {
if (!req.jwt) return res.status(401).end('Not authenticated.');
console.log('Getting user submissions with ID ', req.jwt.user.id);
return res.json(await models.Submission.find({ user: req.jwt.user.id }, 'event user game twitchGame leaderboards category platform estimate runType teams runners video comment status notes invitations incentives')
return res.json(await models.Submission.find({ user: req.jwt.user.id }, 'event user game twitchGame leaderboards category platform estimate runType teams runners video comment commentators status notes invitations incentives')
.populate({ path: 'invitations', populate: { path: 'user', select: 'connections.twitch.displayName connections.twitch.id connections.twitch.logo' } })
.populate({ path: 'teams.members', populate: { path: 'user', select: 'connections.twitch.displayName connections.twitch.id connections.twitch.logo' } }));
}
Expand All @@ -30,7 +30,7 @@ export async function updateUserSubmission(req, res) {
const user = await models.User.findById(req.jwt.user.id, 'roles connections.twitch.name connections.twitch.displayName').populate('roles.role').exec();
// during the submissions period, all these values can be edited. Outside, only run editors can edit everything, otherwise just the alwaysEditable fields can be edited
const fullyEditable = isInSubmissionsPeriod(event) || hasPermission(user, req.body.event, 'Edit Runs');
const validChanges = _.pick(req.body, fullyEditable ? ['game', 'twitchGame', 'leaderboards', 'category', 'platform', 'estimate', 'runType', 'teams', 'video', 'comment', 'invitations', 'incentives'] : event.alwaysEditable);
const validChanges = _.pick(req.body, fullyEditable ? ['game', 'twitchGame', 'leaderboards', 'category', 'platform', 'estimate', 'runType', 'teams', 'video', 'comment', 'commentators', 'invitations', 'incentives'] : event.alwaysEditable);
if (['stub', 'saved', 'deleted'].includes(req.body.status) || (req.body.status && hasPermission(user, req.body.event, 'Edit Runs'))) validChanges.status = req.body.status;

if (!req.body.event) return res.status(400).end('Invalid event ID');
Expand Down Expand Up @@ -121,7 +121,7 @@ export async function updateUserSubmission(req, res) {

export async function getSubmission(req, res) {
if (!req.params.id) return res.status(400).end('Missing query parameter id');
return res.json(await models.Submission.findById(req.params.id, 'event user game twitchGame leaderboards category platform estimate runType teams runners invitations video comment status incentives')
return res.json(await models.Submission.findById(req.params.id, 'event user game twitchGame leaderboards category platform estimate runType teams runners invitations video comment commentators status incentives')
.populate('user', 'connections.twitch.name connections.twitch.displayName connections.twitch.logo connections.srdotcom.name')
.populate({ path: 'teams.members', populate: { path: 'user', select: 'connections.twitch.displayName connections.twitch.id connections.twitch.logo' } })
.populate({ path: 'invitations', populate: { path: 'user', select: 'connections.twitch.displayName connections.twitch.id connections.twitch.logo' } })
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/components/dashboard/SubmissionEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@
</div>
</div>
</div>
<div class="flex-100 layout-column" v-if="currentEvent.needsCommentators !== false">
<md-field class="large-field flex-none" :class="getValidationClass('commentators')">
<label for="commentators">Commentators</label>
<md-input name="commentators" id="commentators" v-model="selectedSubmission.commentators" :disabled="!editable('commentators')" />
<span class="md-error" v-if="!$v.selectedSubmission.commentators.required">At least one commentator is required</span>
</md-field>
</div>
<md-field class="large-field flex-none" :class="getValidationClass('video')">
<label for="video">Video url</label>
<md-input name="video" id="video" v-model="selectedSubmission.video" :disabled="!editable('video')" />
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/dashboard/admin/Events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<md-option v-for="role in roleList" :key="role._id" :value="role._id">{{role.name}}</md-option>
</md-select>
</md-field>
<md-checkbox name="role" id="role" v-model="selectedEvent.commentatorsNeeded">
Enable commentators
</md-checkbox>

<div class="flex-100 layout-row">
<md-datepicker class="medium-field" v-model="selectedEvent.startDate">
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/dashboard/admin/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
data: () => ({
selectedEvent: null,
showDialog: false,
selectableFields: ['game', 'twitchGame', 'leaderboards', 'category', 'platform', 'estimate', 'runType', 'teams', 'video', 'comment', 'invitations', 'incentives'],
selectableFields: ['game', 'twitchGame', 'leaderboards', 'category', 'platform', 'estimate', 'runType', 'teams', 'video', 'comment', 'commentators', 'invitations', 'incentives'],
}),
computed: {
...mapState(['user', 'events', 'roles']),
Expand All @@ -33,6 +33,7 @@ export default {
name: '',
status: 'unpublished',
volunteersNeeded: _.map(this.roleList, role => role._id),
commentatorsNeeded: false,
selectableFields: [],
meta: {
theme: '',
Expand All @@ -56,6 +57,7 @@ export default {
},
selectEvent(event) {
this.selectedEvent = _.merge({
commentatorsNeeded: false,
meta: {
theme: '',
horaro: '',
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/dashboard/submissionedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
maxLength,
helpers,
between,
requiredIf,
} from 'vuelidate/lib/validators';
import Team from './Team.vue';
import settings from '../../settings';
Expand Down Expand Up @@ -260,6 +261,13 @@ export default {
},
},
},
commentators: {
required: requiredIf(() => {
return this.currentEvent.needsCommentators == true && this.selectedSubmission.runType === "race";
}),
minLength: minLength(3),
maxLength: maxLength(1000),
},
incentives: {
$each: {
name: {
Expand Down

0 comments on commit d9389ef

Please sign in to comment.