Skip to content

Commit a6ee38f

Browse files
committed
feat: [#622] force accept agreetment before uploading
1 parent cf18f58 commit a6ee38f

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

cypress.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { grantAdminRole, deleteUser } from "./cypress/e2e/contexts/user/tasks";
33
import { deleteTorrent, deleteTorrentsInfoFromDatabase } from "./cypress/e2e/contexts/torrent/tasks";
44
import { deleteCategory, addCategory } from "./cypress/e2e/contexts/category/tasks";
55
import { deleteTags, addTag } from "./cypress/e2e/contexts/tag/tasks";
6-
import { DatabaseConfig } from "./cypress/e2e/common/database";
6+
import type { DatabaseConfig } from "./cypress/e2e/common/database";
77

88
function databaseConfig (config: Cypress.PluginConfigOptions): DatabaseConfig {
99
return {

cypress/e2e/contexts/torrent/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Cypress.Commands.add("upload_torrent", (torrent_info) => {
2929
// the tags context. We could even create some tags before running all the
3030
// tests.
3131
// cy.get("input[data-cy=\"upload-form-torrent-upload\"]").select('fractals');
32-
32+
cy.get("input[data-cy=\"upload-form-agree-terms\"]").check();
3333
cy.get("button[data-cy=\"upload-form-submit\"]").click();
3434
});
3535

cypress/e2e/contexts/torrent/specs/upload.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe("A registered user", () => {
4444
// the tags context. We could even create some tags before running all the
4545
// tests.
4646
// cy.get("input[data-cy=\"upload-form-torrent-upload\"]").select('fractals');
47-
47+
cy.get("input[data-cy=\"upload-form-agree-terms\"]").check();
4848
cy.get("button[data-cy=\"upload-form-submit\"]").click();
4949

5050
cy.get("@infohash").then((infohash) => {

pages/upload.vue

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
</div>
4242
</template>
4343
</div>
44+
4445
<template v-if="categories?.length > 0">
4546
<div>
4647
<label for="category" class="px-2">Category</label>
@@ -53,6 +54,7 @@
5354
</select>
5455
</div>
5556
</template>
57+
5658
<template v-if="tags?.length > 0">
5759
<div>
5860
<label for="tags" class="px-2">Tags</label>
@@ -67,14 +69,25 @@
6769
<div>
6870
<UploadFile sub-title="Only .torrent files allowed. BitTorrent v2 files are NOT supported." accept=".torrent" @on-change="setFile" />
6971
</div>
72+
73+
<!-- Checkbox for Terms and Conditions Agreement -->
74+
<div>
75+
<label for="agree-to-terms" class="px-2">Agreement</label>
76+
<div class="mt-1">
77+
<input v-model="agreeToTerms" name="agree-to-terms" type="checkbox" class="max-w-5" data-cy="upload-form-agree-terms">
78+
<span class="px-2">I have read the <NuxtLink to="/terms" target="_blank">{{ contentUploadAgreement }}</NuxtLink>.</span>
79+
</div>
80+
</div>
81+
7082
<template v-if="user?.username">
7183
<TorrustButton
7284
label="submit"
7385
data-cy="upload-form-submit"
74-
:disabled="!formValid() || uploading"
86+
:disabled="!formValid() || !agreeToTerms || uploading"
7587
@click="submitForm"
7688
/>
7789
</template>
90+
7891
<template v-else>
7992
<div class="relative flex justify-center text-sm">
8093
<NuxtLink to="/signin">
@@ -101,7 +114,7 @@ import {
101114
useTags,
102115
useUser
103116
} from "#imports";
104-
import { useCategories } from "~/composables/states";
117+
import { useCategories, useSettings } from "~/composables/states";
105118
106119
type FormUploadTorrent = {
107120
title: string;
@@ -111,11 +124,13 @@ type FormUploadTorrent = {
111124
torrentFile: any;
112125
}
113126
127+
const settings = useSettings();
114128
const categories = useCategories();
115129
const tags = useTags();
116130
const user = useUser();
117131
const rest = useRestApi();
118132
133+
const agreeToTerms: Ref<boolean> = ref(false);
119134
const uploading: Ref<boolean> = ref(false);
120135
const descriptionView = ref("edit");
121136
const form: Ref<FormUploadTorrent> = ref({
@@ -125,12 +140,23 @@ const form: Ref<FormUploadTorrent> = ref({
125140
tags: [],
126141
torrentFile: ""
127142
});
143+
const contentUploadAgreement = ref("");
128144
129145
onMounted(() => {
130146
getCategories();
131147
getTags();
132148
});
133149
150+
watch(
151+
() => settings.value,
152+
(newSettings) => {
153+
if (newSettings?.website?.terms?.upload?.content_upload_agreement) {
154+
contentUploadAgreement.value = newSettings.website.terms.page.title;
155+
}
156+
},
157+
{ immediate: true }
158+
);
159+
134160
function formValid () {
135161
return form.value.title && form.value.category && form.value.torrentFile;
136162
}

0 commit comments

Comments
 (0)