added basic support for files

This commit is contained in:
vabene1111
2021-06-08 20:17:48 +02:00
parent c71a7dad24
commit 9eb17df575
17 changed files with 383 additions and 105 deletions

View File

@ -0,0 +1,24 @@
# Generated by Django 3.2.4 on 2021-06-08 17:29
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('cookbook', '0130_alter_userfile_file_size_kb'),
]
operations = [
migrations.AddField(
model_name='step',
name='file',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='cookbook.userfile'),
),
migrations.AlterField(
model_name='step',
name='type',
field=models.CharField(choices=[('TEXT', 'Text'), ('TIME', 'Time'), ('FILE', 'File')], default='TEXT', max_length=16),
),
]

View File

@ -7,6 +7,7 @@ from datetime import date, timedelta
from annoying.fields import AutoOneToOneField from annoying.fields import AutoOneToOneField
from django.contrib import auth from django.contrib import auth
from django.contrib.auth.models import Group, User from django.contrib.auth.models import Group, User
from django.core.files.uploadedfile import UploadedFile, InMemoryUploadedFile
from django.core.validators import MinLengthValidator from django.core.validators import MinLengthValidator
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
@ -332,10 +333,11 @@ class Ingredient(ExportModelOperationsMixin('ingredient'), models.Model, Permiss
class Step(ExportModelOperationsMixin('step'), models.Model, PermissionModelMixin): class Step(ExportModelOperationsMixin('step'), models.Model, PermissionModelMixin):
TEXT = 'TEXT' TEXT = 'TEXT'
TIME = 'TIME' TIME = 'TIME'
FILE = 'FILE'
name = models.CharField(max_length=128, default='', blank=True) name = models.CharField(max_length=128, default='', blank=True)
type = models.CharField( type = models.CharField(
choices=((TEXT, _('Text')), (TIME, _('Time')),), choices=((TEXT, _('Text')), (TIME, _('Time')), (FILE, _('File')),),
default=TEXT, default=TEXT,
max_length=16 max_length=16
) )
@ -343,6 +345,7 @@ class Step(ExportModelOperationsMixin('step'), models.Model, PermissionModelMixi
ingredients = models.ManyToManyField(Ingredient, blank=True) ingredients = models.ManyToManyField(Ingredient, blank=True)
time = models.IntegerField(default=0, blank=True) time = models.IntegerField(default=0, blank=True)
order = models.IntegerField(default=0) order = models.IntegerField(default=0)
file = models.ForeignKey('UserFile', on_delete=models.PROTECT, null=True, blank=True)
show_as_header = models.BooleanField(default=True) show_as_header = models.BooleanField(default=True)
objects = ScopedManager(space='recipe__space') objects = ScopedManager(space='recipe__space')
@ -708,6 +711,7 @@ class UserFile(ExportModelOperationsMixin('user_files'), models.Model, Permissio
space = models.ForeignKey(Space, on_delete=models.CASCADE) space = models.ForeignKey(Space, on_delete=models.CASCADE)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
self.file.name = f'{uuid.uuid4()}' + pathlib.Path(self.file.name).suffix if hasattr(self.file, 'file') and isinstance(self.file.file, UploadedFile) or isinstance(self.file.file, InMemoryUploadedFile):
self.file_size_kb = round(self.file.size / 1000) self.file.name = f'{uuid.uuid4()}' + pathlib.Path(self.file.name).suffix
self.file_size_kb = round(self.file.size / 1000)
super(UserFile, self).save(*args, **kwargs) super(UserFile, self).save(*args, **kwargs)

View File

@ -103,6 +103,20 @@ class UserPreferenceSerializer(serializers.ModelSerializer):
) )
class UserFileSerializer(serializers.ModelSerializer):
def create(self, validated_data):
validated_data['created_by'] = self.context['request'].user
validated_data['space'] = self.context['request'].space
return super().create(validated_data)
class Meta:
model = UserFile
fields = ('name', 'file', 'file_size_kb', 'id',)
read_only_fields = ('id', 'file_size_kb')
extra_kwargs = {"file": {"required": False, }}
class StorageSerializer(SpacedModelSerializer): class StorageSerializer(SpacedModelSerializer):
def create(self, validated_data): def create(self, validated_data):
@ -251,6 +265,7 @@ class StepSerializer(WritableNestedModelSerializer):
ingredients = IngredientSerializer(many=True) ingredients = IngredientSerializer(many=True)
ingredients_markdown = serializers.SerializerMethodField('get_ingredients_markdown') ingredients_markdown = serializers.SerializerMethodField('get_ingredients_markdown')
ingredients_vue = serializers.SerializerMethodField('get_ingredients_vue') ingredients_vue = serializers.SerializerMethodField('get_ingredients_vue')
file = UserFileSerializer(allow_null=True)
def get_ingredients_vue(self, obj): def get_ingredients_vue(self, obj):
return obj.get_instruction_render() return obj.get_instruction_render()
@ -262,7 +277,7 @@ class StepSerializer(WritableNestedModelSerializer):
model = Step model = Step
fields = ( fields = (
'id', 'name', 'type', 'instruction', 'ingredients', 'ingredients_markdown', 'id', 'name', 'type', 'instruction', 'ingredients', 'ingredients_markdown',
'ingredients_vue', 'time', 'order', 'show_as_header' 'ingredients_vue', 'time', 'order', 'show_as_header', 'file',
) )
@ -494,18 +509,6 @@ class BookmarkletImportSerializer(serializers.ModelSerializer):
read_only_fields = ('created_by', 'space') read_only_fields = ('created_by', 'space')
class UserFileSerializer(serializers.ModelSerializer):
def create(self, validated_data):
validated_data['created_by'] = self.context['request'].user
validated_data['space'] = self.context['request'].space
return super().create(validated_data)
class Meta:
model = UserFile
fields = ('id', 'name', 'file_size_kb', 'file')
# Export/Import Serializers # Export/Import Serializers
class KeywordExportSerializer(KeywordSerializer): class KeywordExportSerializer(KeywordSerializer):

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -201,17 +201,40 @@
<select class="form-control" id="id_type" v-model="step.type"> <select class="form-control" id="id_type" v-model="step.type">
<option value="TEXT">{% trans 'Text' %}</option> <option value="TEXT">{% trans 'Text' %}</option>
<option value="TIME">{% trans 'Time' %}</option> <option value="TIME">{% trans 'Time' %}</option>
<option value="FILE">{% trans 'File' %}</option>
</select> </select>
</div> </div>
</div> </div>
<div class="row" style="margin-top: 12px"> <div class="row" style="margin-top: 12px">
<div class="col-md-12"> <div class="col-md-3">
<label :for="'id_step_' + step.id + '_time'">{% trans 'Step time in Minutes' %}</label> <label :for="'id_step_' + step.id + '_time'">{% trans 'Step time in Minutes' %}</label>
<input class="form-control" v-model="step.time" <input class="form-control" v-model="step.time"
:id="'id_step_' + step.id + '_time'"> :id="'id_step_' + step.id + '_time'">
</div> </div>
<div class="col-md-9">
<label :for="'id_step_' + step.id + '_file'">{% trans 'File' %}</label>
<multiselect
v-tabindex
ref="file"
v-model="step.file"
:options="files"
:close-on-select="true"
:clear-on-select="true"
:allow-empty="true"
:preserve-search="true"
placeholder="{% trans 'Select File' %}"
select-label="{% trans 'Select' %}"
:id="'id_step_' + step.id + '_file'"
label="name"
track-by="name"
:multiple="false"
:loading="files_loading"
@search-change="searchFiles">
</multiselect>
</div>
</div> </div>
<template v-if="step.type == 'TEXT'"> <template v-if="step.type == 'TEXT'">
@ -498,6 +521,8 @@
foods_loading: false, foods_loading: false,
units: [], units: [],
units_loading: false, units_loading: false,
files: [],
files_loading: false,
message: '', message: '',
}, },
directives: { directives: {
@ -523,6 +548,7 @@
this.searchUnits('') this.searchUnits('')
this.searchFoods('') this.searchFoods('')
this.searchKeywords('') this.searchKeywords('')
this.searchFiles('')
this._keyListener = function (e) { this._keyListener = function (e) {
if (e.code === "Space" && e.ctrlKey) { if (e.code === "Space" && e.ctrlKey) {
@ -572,6 +598,9 @@
this.sortSteps() this.sortSteps()
for (let s of this.recipe.steps) { for (let s of this.recipe.steps) {
this.sortIngredients(s) this.sortIngredients(s)
if (s.file !== null){
delete s.file.file //TODO stupid quick hack because I cant figure out how to fix the writable serializer right now
}
} }
this.$http.put("{% url 'api:recipe-detail' recipe.pk %}", this.recipe, this.$http.put("{% url 'api:recipe-detail' recipe.pk %}", this.recipe,
{}).then((response) => { {}).then((response) => {
@ -606,8 +635,6 @@
} }
reader.readAsDataURL(event.target.files[0]); reader.readAsDataURL(event.target.files[0]);
} }
}, },
addStep: function () { //TODO see if default can be generated from options request addStep: function () { //TODO see if default can be generated from options request
this.recipe.steps.push( this.recipe.steps.push(
@ -685,6 +712,16 @@
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger')
}) })
}, },
searchFiles: function (query) {
this.files_loading = true
this.$http.get("{% url 'api:userfile-list' %}" + '?query=' + query + '&limit=10').then((response) => {
this.files = response.data
this.files_loading = false
}).catch((err) => {
console.log(err)
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger')
})
},
searchUnits: function (query) { searchUnits: function (query) {
this.units_loading = true this.units_loading = true
this.$http.get("{% url 'api:unit-list' %}" + '?query=' + query + '&limit=10').then((response) => { this.$http.get("{% url 'api:unit-list' %}" + '?query=' + query + '&limit=10').then((response) => {

View File

@ -495,13 +495,15 @@ class BookmarkletImportViewSet(viewsets.ModelViewSet):
return self.queryset.filter(space=self.request.space).all() return self.queryset.filter(space=self.request.space).all()
class UserFileViewSet(viewsets.ModelViewSet): class UserFileViewSet(viewsets.ModelViewSet, StandardFilterMixin):
queryset = UserFile.objects queryset = UserFile.objects
serializer_class = UserFileSerializer serializer_class = UserFileSerializer
permission_classes = [CustomIsUser] permission_classes = [CustomIsUser]
parser_classes = [MultiPartParser]
def get_queryset(self): def get_queryset(self):
return self.queryset.filter(space=self.request.space).all() self.queryset = self.queryset.filter(space=self.request.space).all()
return super().get_queryset()
# -------------- non django rest api views -------------------- # -------------- non django rest api views --------------------

View File

@ -238,7 +238,10 @@ def supermarket(request):
@group_required('user') @group_required('user')
def files(request): def files(request):
current_file_size_mb = UserFile.objects.filter(space=request.space).aggregate(Sum('file_size_kb'))['file_size_kb__sum'] / 1000 try:
current_file_size_mb = UserFile.objects.filter(space=request.space).aggregate(Sum('file_size_kb'))['file_size_kb__sum'] / 1000
except TypeError:
current_file_size_mb = 0
return render(request, 'files.html', {'current_file_size_mb': current_file_size_mb, 'max_file_size_mb': request.space.max_file_storage_mb}) return render(request, 'files.html', {'current_file_size_mb': current_file_size_mb, 'max_file_size_mb': request.space.max_file_storage_mb})
@ -261,9 +264,7 @@ def meal_plan_entry(request, pk):
@group_required('user') @group_required('user')
def latest_shopping_list(request): def latest_shopping_list(request):
sl = ShoppingList.objects.filter(Q(created_by=request.user) | Q(shared=request.user)).filter(finished=False, sl = ShoppingList.objects.filter(Q(created_by=request.user) | Q(shared=request.user)).filter(finished=False, pace=request.space).order_by('-created_at').first()
space=request.space).order_by(
'-created_at').first()
if sl: if sl:
return HttpResponseRedirect(reverse('view_shopping', kwargs={'pk': sl.pk}) + '?edit=true') return HttpResponseRedirect(reverse('view_shopping', kwargs={'pk': sl.pk}) + '?edit=true')

View File

@ -5,7 +5,7 @@
<div class="row"> <div class="row">
<div class="col col-md-12"> <div class="col col-md-12">
<h3>{{ $t('Files') }} <a class="btn btn-success float-right"><i class="fas fa-plus-circle"></i> {{ $t('New') }}</a> <h3>{{ $t('Files') }} <span class="float-right"><file-editor @change="loadInitial()" ></file-editor></span>
</h3> </h3>
</div> </div>
@ -14,8 +14,8 @@
<div class="row" style="margin-top: 2vh"> <div class="row" style="margin-top: 2vh">
<div class="col col-md-12"> <div class="col col-md-12">
<b-progress :max="max_file_size_mb"> <b-progress :max="max_file_size_mb">
<b-progress-bar :value="current_file_size_mb"> <b-progress-bar :value="current_file_size_mb" >
<span><strong>{{ current_file_size_mb.toFixed(2) }} / {{ max_file_size_mb }} MB</strong></span> <span><strong class="text-dark ">{{ current_file_size_mb.toFixed(2) }} / {{ max_file_size_mb }} MB</strong></span>
</b-progress-bar> </b-progress-bar>
</b-progress> </b-progress>
</div> </div>
@ -29,11 +29,16 @@
<tr> <tr>
<th>{{ $t('Name') }}</th> <th>{{ $t('Name') }}</th>
<th>{{ $t('Size') }} (MB)</th> <th>{{ $t('Size') }} (MB)</th>
<th>{{ $t('Edit') }}</th>
</tr> </tr>
</thead> </thead>
<tr v-for="f in files" v-bind:key="f.id"> <tr v-for="f in files" v-bind:key="f.id">
<td>{{ f.name }}</td> <td>{{ f.name }}</td>
<td>{{ f.file_size_kb / 1000 }}</td> <td>{{ f.file_size_kb / 1000 }}</td>
<td><a :href="f.file" target="_blank" rel="noreferrer nofollow">{{$t('Download')}}</a></td>
<td>
<file-editor @change="loadInitial()" :file_id="f.id"></file-editor>
</td>
</tr> </tr>
</table> </table>
</div> </div>
@ -58,6 +63,7 @@ Vue.use(BootstrapVue)
// import draggable from 'vuedraggable' // import draggable from 'vuedraggable'
import axios from 'axios' import axios from 'axios'
import FileEditor from "@/components/FileEditor";
// import Multiselect from "vue-multiselect"; // import Multiselect from "vue-multiselect";
axios.defaults.xsrfHeaderName = 'X-CSRFToken' axios.defaults.xsrfHeaderName = 'X-CSRFToken'
@ -70,8 +76,7 @@ export default {
ToastMixin, ToastMixin,
], ],
components: { components: {
// Multiselect, FileEditor
// draggable
}, },
data() { data() {
return { return {
@ -91,19 +96,6 @@ export default {
apiClient.listUserFiles().then(results => { apiClient.listUserFiles().then(results => {
this.files = results.data this.files = results.data
}) })
},
supermarketModalOk: function () {
let apiClient = new ApiApiFactory()
if (this.selected_supermarket.new) {
apiClient.createSupermarket({name: this.selected_supermarket.name}).then(results => {
this.selected_supermarket = undefined
this.loadInitial()
})
} else {
apiClient.partialUpdateSupermarket(this.selected_supermarket.id, {name: this.selected_supermarket.name})
}
}, },
} }
} }

View File

@ -0,0 +1,93 @@
<template>
<div>
<b-button v-b-modal="'modal-file-editor'+file_id" v-bind:class="{'btn-success': (file_id === undefined)}">
<template v-if="this.file_id">{{ $t('Edit') }}</template>
<template v-else>{{ $t('New') }}</template>
</b-button>
<b-modal :id="'modal-file-editor'+file_id" v-bind:title="$t('File')" @ok="modalOk()">
<template v-if="file!==undefined">
{{ $t('Name') }}
<b-input v-model="file.name"></b-input>
{{ $t('File') }}
<b-form-file v-model="file.file"></b-form-file>
</template>
</b-modal>
</div>
</template>
<script>
import {ApiApiFactory} from "@/utils/openapi/api";
import {makeToast} from "@/utils/utils";
export default {
name: "FileEditor",
data() {
return {
file: undefined
}
},
props: {
file_id: Number,
},
mounted() {
if (this.file_id !== undefined) {
this.loadFile(this.file_id.toString())
} else {
this.file = {
name: '',
file: undefined
}
}
},
methods: {
loadFile: function (id) {
let apiClient = new ApiApiFactory()
apiClient.retrieveUserFile(id).then(result => {
this.file = result.data
})
},
modalOk: function () {
if (this.file_id === undefined) {
console.log('CREATING')
this.createFile()
} else {
console.log('UPDATING')
this.updateFile()
}
},
updateFile: function () {
let apiClient = new ApiApiFactory()
let passedFile = undefined
if (!(typeof this.file.file === 'string' || this.file.file instanceof String)) { // only update file if it was changed
passedFile = this.file.file
}
console.log(passedFile)
apiClient.updateUserFile(this.file.id, this.file.name, passedFile).then(request => {
makeToast(this.$t('Success'), this.$t('success_updating_resource'), 'success')
this.$emit('change',)
}).catch(err => {
makeToast(this.$t('Error'), this.$t('err_updating_resource'), 'danger')
console.log(err.request, err.response)
})
},
createFile: function () {
let apiClient = new ApiApiFactory()
apiClient.createUserFile(this.file.name, this.file.file).then(request => {
makeToast(this.$t('Success'), this.$t('success_creating_resource'), 'success')
this.$emit('change',)
}).catch(err => {
makeToast(this.$t('Error'), this.$t('err_creating_resource'), 'danger')
console.log(err.request, err.response)
})
}
}
}
</script>

View File

@ -34,19 +34,21 @@
<table class="table table-sm"> <table class="table table-sm">
<!-- eslint-disable vue/no-v-for-template-key-on-child --> <!-- eslint-disable vue/no-v-for-template-key-on-child -->
<template v-for="i in step.ingredients"> <template v-for="i in step.ingredients">
<Ingredient v-bind:ingredient="i" :ingredient_factor="ingredient_factor" :key="i.id" @checked-state-changed="$emit('checked-state-changed', i)"></Ingredient> <Ingredient v-bind:ingredient="i" :ingredient_factor="ingredient_factor" :key="i.id"
@checked-state-changed="$emit('checked-state-changed', i)"></Ingredient>
</template> </template>
<!-- eslint-enable vue/no-v-for-template-key-on-child --> <!-- eslint-enable vue/no-v-for-template-key-on-child -->
</table> </table>
</div> </div>
<div class="col" :class="{ 'col-md-8': recipe.steps.length > 1, 'col-md-12': recipe.steps.length <= 1,}"> <div class="col" :class="{ 'col-md-8': recipe.steps.length > 1, 'col-md-12': recipe.steps.length <= 1,}">
<compile-component :code="step.ingredients_markdown" :ingredient_factor="ingredient_factor"></compile-component> <compile-component :code="step.ingredients_markdown"
:ingredient_factor="ingredient_factor"></compile-component>
</div> </div>
</div> </div>
</b-collapse> </b-collapse>
</template> </template>
<template v-if="step.type === 'TIME'"> <template v-if="step.type === 'TIME' || step.type === 'FILE'">
<div class="row"> <div class="row">
<div class="col-md-8 offset-md-2" style="text-align: center"> <div class="col-md-8 offset-md-2" style="text-align: center">
<h4 class="text-primary"> <h4 class="text-primary">
@ -55,7 +57,8 @@
</h4> </h4>
<span style="margin-left: 4px" class="text-muted" v-if="step.time !== 0"><i class="fa fa-stopwatch"></i> <span style="margin-left: 4px" class="text-muted" v-if="step.time !== 0"><i class="fa fa-stopwatch"></i>
{{ step.time }} {{ $t('min') }}</span> {{ step.time }} {{ $t('min') }}</span>
<b-link class="d-print-none" :id="`id_reactive_popover_${step.id}`" @click="openPopover" href="#" v-if="start_time !== ''"> <b-link class="d-print-none" :id="`id_reactive_popover_${step.id}`" @click="openPopover" href="#"
v-if="start_time !== ''">
{{ moment(start_time).add(step.time_offset, 'minutes').format('HH:mm') }} {{ moment(start_time).add(step.time_offset, 'minutes').format('HH:mm') }}
</b-link> </b-link>
</div> </div>
@ -71,12 +74,28 @@
<b-collapse id="collapse-1" v-model="details_visible"> <b-collapse id="collapse-1" v-model="details_visible">
<div class="row" v-if="step.instruction !== ''"> <div class="row" v-if="step.instruction !== ''">
<div class="col col-md-12" style="text-align: center"> <div class="col col-md-12" style="text-align: center">
<compile-component :code="step.ingredients_markdown" :ingredient_factor="ingredient_factor"></compile-component> <compile-component :code="step.ingredients_markdown"
:ingredient_factor="ingredient_factor"></compile-component>
</div> </div>
</div> </div>
</b-collapse> </b-collapse>
</template> </template>
<div class="row" style="text-align: center">
<div class="col col-md-12">
<template v-if="step.file !== null">
<div
v-if="step.file.file.includes('.png') || recipe.file_path.includes('.jpg') || recipe.file_path.includes('.jpeg') || recipe.file_path.includes('.gif')">
<img :src="step.file.file" style="max-width: 50vw; max-height: 50vh">
</div>
<div v-else>
<a :href="step.file.file" target="_blank" rel="noreferrer nofollow">{{ $t('Download') }} {{ $t('File') }}</a>
</div>
</template>
</div>
</div>
<div v-if="start_time !== ''"> <div v-if="start_time !== ''">
<b-popover <b-popover
:target="`id_reactive_popover_${step.id}`" :target="`id_reactive_popover_${step.id}`"

View File

@ -1,4 +1,11 @@
{ {
"err_fetching_resource": "There was an error fetching a resource!",
"err_creating_resource": "There was an error creating a resource!",
"err_updating_resource": "There was an error updating a resource!",
"success_fetching_resource": "Successfully fetched a resource!",
"success_creating_resource": "Successfully created a resource!",
"success_updating_resource": "Successfully updated a resource!",
"import_running": "Import running, please wait!", "import_running": "Import running, please wait!",
"all_fields_optional": "All fields are optional and can be left empty.", "all_fields_optional": "All fields are optional and can be left empty.",
"convert_internal": "Convert to internal recipe", "convert_internal": "Convert to internal recipe",
@ -38,6 +45,7 @@
"Close": "Close", "Close": "Close",
"Add": "Add", "Add": "Add",
"New": "New", "New": "New",
"Success": "Success",
"Ingredients": "Ingredients", "Ingredients": "Ingredients",
"Supermarket": "Supermarket", "Supermarket": "Supermarket",
"Categories": "Categories", "Categories": "Categories",
@ -50,6 +58,7 @@
"External": "External", "External": "External",
"Size": "Size", "Size": "Size",
"Files": "Files", "Files": "Files",
"File": "File",
"Edit": "Edit", "Edit": "Edit",
"Open": "Open", "Open": "Open",
"Save": "Save", "Save": "Save",
@ -60,5 +69,6 @@
"Settings": "Settings", "Settings": "Settings",
"or": "or", "or": "or",
"and": "and", "and": "and",
"Information": "Information" "Information": "Information",
"Download": "Download"
} }

View File

@ -1778,18 +1778,18 @@ export interface Unit {
* @interface UserFile * @interface UserFile
*/ */
export interface UserFile { export interface UserFile {
/**
*
* @type {number}
* @memberof UserFile
*/
id?: number;
/** /**
* *
* @type {string} * @type {string}
* @memberof UserFile * @memberof UserFile
*/ */
name: string; name: string;
/**
*
* @type {any}
* @memberof UserFile
*/
file?: any;
/** /**
* *
* @type {number} * @type {number}
@ -1798,10 +1798,10 @@ export interface UserFile {
file_size_kb?: number; file_size_kb?: number;
/** /**
* *
* @type {any} * @type {number}
* @memberof UserFile * @memberof UserFile
*/ */
file: any; id?: number;
} }
/** /**
* *
@ -2634,11 +2634,16 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
}, },
/** /**
* *
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
createUserFile: async (userFile?: UserFile, options: any = {}): Promise<RequestArgs> => { createUserFile: async (name: string, file?: any, fileSizeKb?: number, id?: number, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'name' is not null or undefined
assertParamExists('createUserFile', 'name', name)
const localVarPath = `/api/user-file/`; const localVarPath = `/api/user-file/`;
// use dummy base URL string because the URL constructor only accepts absolute URLs. // use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@ -2650,15 +2655,32 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any; const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any; const localVarQueryParameter = {} as any;
const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
if (name !== undefined) {
localVarFormParams.append('name', name as any);
}
if (file !== undefined) {
localVarFormParams.append('file', file as any);
}
if (fileSizeKb !== undefined) {
localVarFormParams.append('file_size_kb', fileSizeKb as any);
}
if (id !== undefined) {
localVarFormParams.append('id', id as any);
}
localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(userFile, localVarRequestOptions, configuration) localVarRequestOptions.data = localVarFormParams;
return { return {
url: toPathString(localVarUrlObj), url: toPathString(localVarUrlObj),
@ -5055,13 +5077,18 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
/** /**
* *
* @param {string} id A unique integer value identifying this user file. * @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
partialUpdateUserFile: async (id: string, userFile?: UserFile, options: any = {}): Promise<RequestArgs> => { partialUpdateUserFile: async (id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined // verify required parameter 'id' is not null or undefined
assertParamExists('partialUpdateUserFile', 'id', id) assertParamExists('partialUpdateUserFile', 'id', id)
// verify required parameter 'name' is not null or undefined
assertParamExists('partialUpdateUserFile', 'name', name)
const localVarPath = `/api/user-file/{id}/` const localVarPath = `/api/user-file/{id}/`
.replace(`{${"id"}}`, encodeURIComponent(String(id))); .replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs. // use dummy base URL string because the URL constructor only accepts absolute URLs.
@ -5074,15 +5101,32 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options}; const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any; const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any; const localVarQueryParameter = {} as any;
const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
if (name !== undefined) {
localVarFormParams.append('name', name as any);
}
if (file !== undefined) {
localVarFormParams.append('file', file as any);
}
if (fileSizeKb !== undefined) {
localVarFormParams.append('file_size_kb', fileSizeKb as any);
}
if (id2 !== undefined) {
localVarFormParams.append('id', id2 as any);
}
localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(userFile, localVarRequestOptions, configuration) localVarRequestOptions.data = localVarFormParams;
return { return {
url: toPathString(localVarUrlObj), url: toPathString(localVarUrlObj),
@ -6731,13 +6775,18 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
/** /**
* *
* @param {string} id A unique integer value identifying this user file. * @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
updateUserFile: async (id: string, userFile?: UserFile, options: any = {}): Promise<RequestArgs> => { updateUserFile: async (id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined // verify required parameter 'id' is not null or undefined
assertParamExists('updateUserFile', 'id', id) assertParamExists('updateUserFile', 'id', id)
// verify required parameter 'name' is not null or undefined
assertParamExists('updateUserFile', 'name', name)
const localVarPath = `/api/user-file/{id}/` const localVarPath = `/api/user-file/{id}/`
.replace(`{${"id"}}`, encodeURIComponent(String(id))); .replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs. // use dummy base URL string because the URL constructor only accepts absolute URLs.
@ -6750,15 +6799,32 @@ export const ApiApiAxiosParamCreator = function (configuration?: Configuration)
const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any; const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any; const localVarQueryParameter = {} as any;
const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
if (name !== undefined) {
localVarFormParams.append('name', name as any);
}
if (file !== undefined) {
localVarFormParams.append('file', file as any);
}
if (fileSizeKb !== undefined) {
localVarFormParams.append('file_size_kb', fileSizeKb as any);
}
if (id2 !== undefined) {
localVarFormParams.append('id', id2 as any);
}
localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(userFile, localVarRequestOptions, configuration) localVarRequestOptions.data = localVarFormParams;
return { return {
url: toPathString(localVarUrlObj), url: toPathString(localVarUrlObj),
@ -7051,12 +7117,15 @@ export const ApiApiFp = function(configuration?: Configuration) {
}, },
/** /**
* *
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async createUserFile(userFile?: UserFile, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> { async createUserFile(name: string, file?: any, fileSizeKb?: number, id?: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.createUserFile(userFile, options); const localVarAxiosArgs = await localVarAxiosParamCreator.createUserFile(name, file, fileSizeKb, id, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
}, },
/** /**
@ -7779,12 +7848,15 @@ export const ApiApiFp = function(configuration?: Configuration) {
/** /**
* *
* @param {string} id A unique integer value identifying this user file. * @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async partialUpdateUserFile(id: string, userFile?: UserFile, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> { async partialUpdateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.partialUpdateUserFile(id, userFile, options); const localVarAxiosArgs = await localVarAxiosParamCreator.partialUpdateUserFile(id, name, file, fileSizeKb, id2, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
}, },
/** /**
@ -8282,12 +8354,15 @@ export const ApiApiFp = function(configuration?: Configuration) {
/** /**
* *
* @param {string} id A unique integer value identifying this user file. * @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async updateUserFile(id: string, userFile?: UserFile, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> { async updateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserFile>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateUserFile(id, userFile, options); const localVarAxiosArgs = await localVarAxiosParamCreator.updateUserFile(id, name, file, fileSizeKb, id2, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
}, },
/** /**
@ -8504,12 +8579,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?:
}, },
/** /**
* *
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
createUserFile(userFile?: UserFile, options?: any): AxiosPromise<UserFile> { createUserFile(name: string, file?: any, fileSizeKb?: number, id?: number, options?: any): AxiosPromise<UserFile> {
return localVarFp.createUserFile(userFile, options).then((request) => request(axios, basePath)); return localVarFp.createUserFile(name, file, fileSizeKb, id, options).then((request) => request(axios, basePath));
}, },
/** /**
* *
@ -9160,12 +9238,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?:
/** /**
* *
* @param {string} id A unique integer value identifying this user file. * @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
partialUpdateUserFile(id: string, userFile?: UserFile, options?: any): AxiosPromise<UserFile> { partialUpdateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any): AxiosPromise<UserFile> {
return localVarFp.partialUpdateUserFile(id, userFile, options).then((request) => request(axios, basePath)); return localVarFp.partialUpdateUserFile(id, name, file, fileSizeKb, id2, options).then((request) => request(axios, basePath));
}, },
/** /**
* *
@ -9615,12 +9696,15 @@ export const ApiApiFactory = function (configuration?: Configuration, basePath?:
/** /**
* *
* @param {string} id A unique integer value identifying this user file. * @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
updateUserFile(id: string, userFile?: UserFile, options?: any): AxiosPromise<UserFile> { updateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any): AxiosPromise<UserFile> {
return localVarFp.updateUserFile(id, userFile, options).then((request) => request(axios, basePath)); return localVarFp.updateUserFile(id, name, file, fileSizeKb, id2, options).then((request) => request(axios, basePath));
}, },
/** /**
* *
@ -9874,13 +9958,16 @@ export class ApiApi extends BaseAPI {
/** /**
* *
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
* @memberof ApiApi * @memberof ApiApi
*/ */
public createUserFile(userFile?: UserFile, options?: any) { public createUserFile(name: string, file?: any, fileSizeKb?: number, id?: number, options?: any) {
return ApiApiFp(this.configuration).createUserFile(userFile, options).then((request) => request(this.axios, this.basePath)); return ApiApiFp(this.configuration).createUserFile(name, file, fileSizeKb, id, options).then((request) => request(this.axios, this.basePath));
} }
/** /**
@ -10674,13 +10761,16 @@ export class ApiApi extends BaseAPI {
/** /**
* *
* @param {string} id A unique integer value identifying this user file. * @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
* @memberof ApiApi * @memberof ApiApi
*/ */
public partialUpdateUserFile(id: string, userFile?: UserFile, options?: any) { public partialUpdateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any) {
return ApiApiFp(this.configuration).partialUpdateUserFile(id, userFile, options).then((request) => request(this.axios, this.basePath)); return ApiApiFp(this.configuration).partialUpdateUserFile(id, name, file, fileSizeKb, id2, options).then((request) => request(this.axios, this.basePath));
} }
/** /**
@ -11225,13 +11315,16 @@ export class ApiApi extends BaseAPI {
/** /**
* *
* @param {string} id A unique integer value identifying this user file. * @param {string} id A unique integer value identifying this user file.
* @param {UserFile} [userFile] * @param {string} name
* @param {any} [file]
* @param {number} [fileSizeKb]
* @param {number} [id2]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
* @memberof ApiApi * @memberof ApiApi
*/ */
public updateUserFile(id: string, userFile?: UserFile, options?: any) { public updateUserFile(id: string, name: string, file?: any, fileSizeKb?: number, id2?: number, options?: any) {
return ApiApiFp(this.configuration).updateUserFile(id, userFile, options).then((request) => request(this.axios, this.basePath)); return ApiApiFp(this.configuration).updateUserFile(id, name, file, fileSizeKb, id2, options).then((request) => request(this.axios, this.basePath));
} }
/** /**