FEATURE fix permissions model

This commit is contained in:
konrad.lys@eu.equinix.com
2023-05-28 10:50:03 +02:00
parent 96ae4ae758
commit fce44c9fbb
4 changed files with 71 additions and 7 deletions

View File

@@ -22,7 +22,16 @@
"archived_file_name": "2022-03-22 no latin title.pdf",
"owner": null,
"user_can_change": true,
"permissions": {
"view": {
"users": [],
"groups": []
},
"change": {
"users": [],
"groups": []
}
},
"notes": [
{
"id": 9,
@@ -61,7 +70,16 @@
"archived_file_name": "2022-03-23 llorem ipsum dolor sit amet.pdf",
"owner": null,
"user_can_change": true,
"permissions": {
"view": {
"users": [],
"groups": []
},
"change": {
"users": [],
"groups": []
}
},
"notes": []
},
{
@@ -83,7 +101,16 @@
"archived_file_name": "2022-03-24 dolor.pdf",
"owner": null,
"user_can_change": true,
"permissions": {
"view": {
"users": [],
"groups": []
},
"change": {
"users": [],
"groups": []
}
},
"notes": []
},
{
@@ -105,7 +132,16 @@
"archived_file_name": "2022-06-01 sit amet.pdf",
"owner": null,
"user_can_change": true,
"permissions": {
"view": {
"users": [],
"groups": []
},
"change": {
"users": [],
"groups": []
}
},
"notes": []
},
{
@@ -125,7 +161,16 @@
"archived_file_name": "doc5.pdf",
"owner": 15,
"user_can_change": true,
"permissions": {
"view": {
"users": [],
"groups": []
},
"change": {
"users": [],
"groups": []
}
},
"notes": []
},
{

View File

@@ -30,6 +30,7 @@ class PaperlessApiHiveTypeIds {
static const int groupModel = 124;
static const int permissions = 125;
static const int userModelv2 = 126;
static const int usersAndGroupsPermissions = 127;
}
void registerPaperlessApiHiveTypeAdapters() {

View File

@@ -1,6 +1,7 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hive/hive.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_api/src/models/permissions/users_and_groups_permissions.dart';
part 'permissions.freezed.dart';
part 'permissions.g.dart';
@@ -9,8 +10,8 @@ part 'permissions.g.dart';
@freezed
class Permissions with _$Permissions {
const factory Permissions({
@HiveField(0) @Default([]) List<int> view,
@HiveField(1) @Default([]) List<int> change,
@HiveField(0) required UsersAndGroupsPermissions view,
@HiveField(1) required UsersAndGroupsPermissions change,
}) = _Permissions;
factory Permissions.fromJson(Map<String, dynamic> json) => _$PermissionsFromJson(json);

View File

@@ -0,0 +1,17 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hive/hive.dart';
import 'package:paperless_api/paperless_api.dart';
part 'users_and_groups_permissions.freezed.dart';
part 'users_and_groups_permissions.g.dart';
@HiveType(typeId: PaperlessApiHiveTypeIds.usersAndGroupsPermissions)
@freezed
class UsersAndGroupsPermissions with _$UsersAndGroupsPermissions {
const factory UsersAndGroupsPermissions({
@HiveField(0) @Default([]) List<int> users,
@HiveField(1) @Default([]) List<int> groups,
}) = _UsersAndGroupsPermissions;
factory UsersAndGroupsPermissions.fromJson(Map<String, dynamic> json) => _$UsersAndGroupsPermissionsFromJson(json);
}