Skip to content

Commit

Permalink
restriction for import_preview
Browse files Browse the repository at this point in the history
  • Loading branch information
ostcar committed Oct 3, 2023
1 parent 0c5eac4 commit 2af4fd2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
11 changes: 2 additions & 9 deletions internal/restrict/collection/import_preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ package collection

import (
"context"
"errors"

"github.com/OpenSlides/openslides-autoupdate-service/pkg/datastore/dsfetch"
)

// ImportPreview handels restrictions of the collection import_preview.
//
// The user can see a import_preview, if TODO
//
// Mode A: The user can see the import_preview.
// Noone can see the import_preview
type ImportPreview struct{}

// Name returns the collection name.
Expand All @@ -28,11 +25,7 @@ func (i ImportPreview) MeetingID(ctx context.Context, ds *dsfetch.Fetch, id int)
func (i ImportPreview) Modes(mode string) FieldRestricter {
switch mode {
case "A":
return i.see
return never
}
return nil
}

func (i ImportPreview) see(ctx context.Context, ds *dsfetch.Fetch, importPreviewIDs ...int) ([]int, error) {
return nil, errors.New("TODO")
}
29 changes: 29 additions & 0 deletions internal/restrict/collection/import_preview_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package collection_test

import (
"testing"

"github.com/OpenSlides/openslides-autoupdate-service/internal/restrict/collection"
)

func TestImportPreviewModeA(t *testing.T) {
var i collection.ImportPreview

testCase(
"no perms",
t,
i.Modes("A"),
false,
``,
)

testCase(
"organization manager",
t,
i.Modes("A"),
false,
`---
user/1/organization_management_level: can_manage_organization
`,
)
}

0 comments on commit 2af4fd2

Please sign in to comment.