feat: organisation logo (attachOne logo) and payload helpers
- Organisation gains the public attachOne logo (OrganisationLogoField), editable as an image upload on the Organisations form; avatar unchanged - OrganisationLogoURL and OrganisationLogoFields give applications the has_logo, logo and logo_url keys for their organisation payloads - no migration: attachments live in system_files
This commit is contained in:
@@ -53,9 +53,9 @@ func TestAdminModelContracts(t *testing.T) {
|
||||
if (User{}).MorphName() != `Golem15\User\Models\User` || (Organisation{}).MorphName() != `Golem15\User\Models\Organisation` {
|
||||
t.Fatalf("morph names = %q / %q", (User{}).MorphName(), (Organisation{}).MorphName())
|
||||
}
|
||||
for name, relations := range map[string]int{"user": len((User{}).AttachRelations()), "organisation": len((Organisation{}).AttachRelations())} {
|
||||
if relations != 1 {
|
||||
t.Fatalf("%s attach relations = %d", name, relations)
|
||||
for name, want := range map[string][2]int{"user": {len((User{}).AttachRelations()), 1}, "organisation": {len((Organisation{}).AttachRelations()), 2}} {
|
||||
if want[0] != want[1] {
|
||||
t.Fatalf("%s attach relations = %d, want %d", name, want[0], want[1])
|
||||
}
|
||||
}
|
||||
if rel := (User{}).AttachRelations()[0]; AvatarField != "avatar" || rel.Name != AvatarField || !rel.Public {
|
||||
@@ -64,6 +64,9 @@ func TestAdminModelContracts(t *testing.T) {
|
||||
if rel := (Organisation{}).AttachRelations()[0]; rel.Name != OrganisationAvatarField || !rel.Public {
|
||||
t.Fatalf("organisation avatar relation = %+v", rel)
|
||||
}
|
||||
if rel := (Organisation{}).AttachRelations()[1]; OrganisationLogoField != "logo" || rel.Name != OrganisationLogoField || !rel.Public {
|
||||
t.Fatalf("organisation logo relation = %+v", rel)
|
||||
}
|
||||
|
||||
if got := (User{}).FilterScopes(); !reflect.DeepEqual(got, []string{FilterByGroup}) || FilterByGroup != "filterByGroup" {
|
||||
t.Fatalf("User.FilterScopes = %v", got)
|
||||
|
||||
@@ -34,9 +34,15 @@ func (Organisation) MorphName() string { return `Golem15\User\Models\Organisatio
|
||||
// organisation's picture.
|
||||
const OrganisationAvatarField = "avatar"
|
||||
|
||||
// AttachRelations declares the public attachOne avatar (PHP $attachOne).
|
||||
// OrganisationLogoField is the attachOne relation name of the
|
||||
// organisation's logo, the image a site shows wherever it displays the
|
||||
// organisation.
|
||||
const OrganisationLogoField = "logo"
|
||||
|
||||
// AttachRelations declares the public attachOne avatar (PHP $attachOne) and
|
||||
// the public attachOne logo.
|
||||
func (Organisation) AttachRelations() []attach.Relation {
|
||||
return []attach.Relation{{Name: OrganisationAvatarField, Public: true}}
|
||||
return []attach.Relation{{Name: OrganisationAvatarField, Public: true}, {Name: OrganisationLogoField, Public: true}}
|
||||
}
|
||||
|
||||
// Fillable is the PHP $fillable list.
|
||||
|
||||
@@ -22,6 +22,13 @@ fields:
|
||||
mode: image
|
||||
imageWidth: 120
|
||||
imageHeight: 120
|
||||
logo:
|
||||
label: golem15.user::lang.organisation.logo
|
||||
comment: golem15.user::lang.organisation.logo_comment
|
||||
type: fileupload
|
||||
mode: image
|
||||
imageWidth: 240
|
||||
imageHeight: 120
|
||||
members:
|
||||
type: relation-manager
|
||||
relation: members
|
||||
|
||||
Reference in New Issue
Block a user