-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathusers.go
More file actions
48 lines (41 loc) · 1.19 KB
/
users.go
File metadata and controls
48 lines (41 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package api
import (
"fmt"
)
// User is the definition of the user object.
type User struct {
ID int `json:"id"`
LastLogin string `json:"last_login"`
IsSuperuser bool `json:"is_superuser"`
Username string `json:"username"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
IsStaff bool `json:"is_staff"`
IsActive bool `json:"is_active"`
DateJoined string `json:"date_joined"`
}
func (u User) String() string {
tpl := `ID: %d
Username: %s
Email: %s
First Name: %s
Last Name: %s
Last Login: %s
Is Superuser: %t
Is Staff: %t
Is Active: %t
Date Joined: %s`
return fmt.Sprintf(tpl, u.ID, u.Username, u.Email, u.FirstName, u.LastName, u.LastLogin,
u.IsSuperuser, u.IsStaff, u.IsActive, u.DateJoined)
}
// Users holds a collection of user objects.
type Users []User
func (u Users) Len() int { return len(u) }
func (u Users) Swap(i, j int) { u[i], u[j] = u[j], u[i] }
func (u Users) Less(i, j int) bool { return u[i].Username < u[j].Username }
// UserApps is a definition of the UserFromKey Hook response.
type UserApps struct {
Username string `json:"username"`
Apps []string `json:"apps"`
}