Can now update user quota in UI

This commit is contained in:
Eliot Berriot 2018-09-28 20:45:31 +02:00
parent 68540cf4ab
commit d000a1329f
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
2 changed files with 29 additions and 2 deletions

View File

@ -93,11 +93,13 @@ class ManageUserSimpleSerializer(serializers.ModelSerializer):
"date_joined", "date_joined",
"last_activity", "last_activity",
"privacy_level", "privacy_level",
"upload_quota",
) )
class ManageUserSerializer(serializers.ModelSerializer): class ManageUserSerializer(serializers.ModelSerializer):
permissions = PermissionsSerializer(source="*") permissions = PermissionsSerializer(source="*")
upload_quota = serializers.IntegerField(allow_null=True)
class Meta: class Meta:
model = users_models.User model = users_models.User
@ -113,6 +115,7 @@ class ManageUserSerializer(serializers.ModelSerializer):
"last_activity", "last_activity",
"permissions", "permissions",
"privacy_level", "privacy_level",
"upload_quota",
) )
read_only_fields = [ read_only_fields = [
"id", "id",

View File

@ -78,6 +78,25 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr>
<td>
<translate>Upload quota</translate>
<span :data-tooltip="labels.uploadQuota"><i class="question circle icon"></i></span>
</td>
<td>
<div class="ui right labeled input">
<input
class="ui input"
@change="update('upload_quota', true)"
v-model.number="object.upload_quota"
step="100"
type="number" />
<div class="ui basic label">
<translate>MB</translate>
</div>
</div>
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@ -122,8 +141,12 @@ export default {
self.isLoading = false self.isLoading = false
}) })
}, },
update (attr) { update (attr, toNull) {
let newValue = this.object[attr] let newValue = this.object[attr]
if (toNull && !newValue) {
newValue = null
}
console.log(newValue, typeof(newValue))
let params = {} let params = {}
if (attr === 'permissions') { if (attr === 'permissions') {
params['permissions'] = {} params['permissions'] = {}
@ -143,7 +166,8 @@ export default {
computed: { computed: {
labels () { labels () {
return { return {
inactive: this.$gettext('Determine if the user account is active or not. Inactive users cannot login or use the service.') inactive: this.$gettext('Determine if the user account is active or not. Inactive users cannot login or use the service.'),
uploadQuota: this.$gettext('Determine how much content the user can upload. Leave empty to use the default value of the instance.')
} }
}, },
allPermissions () { allPermissions () {