mirror of
https://github.com/hay-kot/homebox.git
synced 2025-06-01 01:52:30 +00:00
feat: Notifiers CRUD (#337)
* introduce scaffold for new models * wip: shoutrrr wrapper (may remove) * update schema files * gen: ent code * gen: migrations * go mod tidy * add group_id to notifier * db migration * new mapper helpers * notifier repo * introduce experimental adapter pattern for hdlrs * refactor adapters to fit more common use cases * new routes for notifiers * update errors to fix validation panic * go tidy * reverse checkbox label display * wip: notifiers UI * use badges instead of text * improve documentation * add scaffold schema reference * remove notifier service * refactor schema folder * support group edges via scaffold * delete test file * include link to API docs * audit and update documentation + improve format * refactor schema edges * refactor * add custom validator * set validate + order fields by name * fix failing tests
This commit is contained in:
parent
2665b666f1
commit
23b5892aef
100 changed files with 11437 additions and 2075 deletions
|
@ -30,10 +30,10 @@ type User struct {
|
|||
Password string `json:"-"`
|
||||
// IsSuperuser holds the value of the "is_superuser" field.
|
||||
IsSuperuser bool `json:"is_superuser,omitempty"`
|
||||
// Role holds the value of the "role" field.
|
||||
Role user.Role `json:"role,omitempty"`
|
||||
// Superuser holds the value of the "superuser" field.
|
||||
Superuser bool `json:"superuser,omitempty"`
|
||||
// Role holds the value of the "role" field.
|
||||
Role user.Role `json:"role,omitempty"`
|
||||
// ActivatedOn holds the value of the "activated_on" field.
|
||||
ActivatedOn time.Time `json:"activated_on,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
|
@ -48,9 +48,11 @@ type UserEdges struct {
|
|||
Group *Group `json:"group,omitempty"`
|
||||
// AuthTokens holds the value of the auth_tokens edge.
|
||||
AuthTokens []*AuthTokens `json:"auth_tokens,omitempty"`
|
||||
// Notifiers holds the value of the notifiers edge.
|
||||
Notifiers []*Notifier `json:"notifiers,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [2]bool
|
||||
loadedTypes [3]bool
|
||||
}
|
||||
|
||||
// GroupOrErr returns the Group value or an error if the edge
|
||||
|
@ -75,6 +77,15 @@ func (e UserEdges) AuthTokensOrErr() ([]*AuthTokens, error) {
|
|||
return nil, &NotLoadedError{edge: "auth_tokens"}
|
||||
}
|
||||
|
||||
// NotifiersOrErr returns the Notifiers value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) NotifiersOrErr() ([]*Notifier, error) {
|
||||
if e.loadedTypes[2] {
|
||||
return e.Notifiers, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "notifiers"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*User) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
|
@ -147,18 +158,18 @@ func (u *User) assignValues(columns []string, values []any) error {
|
|||
} else if value.Valid {
|
||||
u.IsSuperuser = value.Bool
|
||||
}
|
||||
case user.FieldRole:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field role", values[i])
|
||||
} else if value.Valid {
|
||||
u.Role = user.Role(value.String)
|
||||
}
|
||||
case user.FieldSuperuser:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field superuser", values[i])
|
||||
} else if value.Valid {
|
||||
u.Superuser = value.Bool
|
||||
}
|
||||
case user.FieldRole:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field role", values[i])
|
||||
} else if value.Valid {
|
||||
u.Role = user.Role(value.String)
|
||||
}
|
||||
case user.FieldActivatedOn:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field activated_on", values[i])
|
||||
|
@ -187,6 +198,11 @@ func (u *User) QueryAuthTokens() *AuthTokensQuery {
|
|||
return NewUserClient(u.config).QueryAuthTokens(u)
|
||||
}
|
||||
|
||||
// QueryNotifiers queries the "notifiers" edge of the User entity.
|
||||
func (u *User) QueryNotifiers() *NotifierQuery {
|
||||
return NewUserClient(u.config).QueryNotifiers(u)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this User.
|
||||
// Note that you need to call User.Unwrap() before calling this method if this User
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
|
@ -227,12 +243,12 @@ func (u *User) String() string {
|
|||
builder.WriteString("is_superuser=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.IsSuperuser))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("role=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Role))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("superuser=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Superuser))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("role=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Role))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("activated_on=")
|
||||
builder.WriteString(u.ActivatedOn.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue