Explorar o código

Generate template files for groups

Andrea Fazzi %!s(int64=5) %!d(string=hai) anos
pai
achega
012d1b935a

+ 20 - 0
compose/karmen/ldap/bootstrap/ldif/foo.org.ldif

@@ -51,6 +51,26 @@ gidNumber: 6001
 objectclass: posixGroup
 objectclass: top
 
+dn: ou=Segreterie,ou=Groups,dc=foo,dc=org
+changetype: add
+ou: Segreterie
+objectclass: organizationalUnit
+objectclass: top
+
+dn: cn=Segreteria del personale,ou=Segreterie,ou=Groups,dc=foo,dc=org
+changetype: add
+cn: Segreteria del personale
+gidNumber: 6015
+objectclass: posixGroup
+objectclass: top
+
+dn: cn=Segreteria didattica,ou=Segreterie,ou=Groups,dc=foo,dc=org
+changetype: add
+cn: Segreteria didattica
+gidNumber: 6016
+objectclass: posixGroup
+objectclass: top
+
 dn: ou=Dipartimenti,ou=Groups,dc=foo,dc=org
 changetype: add
 ou: Dipartimenti

+ 1 - 0
handlers/handlers.go

@@ -60,6 +60,7 @@ var (
 		"students",
 		"offices",
 		"administratives",
+		"groups",
 	}
 )
 

+ 42 - 1
orm/group.go

@@ -1,9 +1,50 @@
 package orm
 
-import "github.com/jinzhu/gorm"
+import (
+	"net/http"
+
+	"github.com/jinzhu/gorm"
+)
 
 type Group struct {
 	gorm.Model
 
 	Name string
 }
+
+func GetGroupsAll(args map[string]string) (interface{}, error) {
+	var groups []*Group
+	if err := DB().Order("name").Find(&groups).Error; err != nil {
+		return nil, err
+	}
+
+	return groups, nil
+}
+
+func GetGroupAll(args map[string]string) (interface{}, error) {
+	return nil, nil
+}
+
+func GetGroupForUpdate(args map[string]string) (interface{}, error) {
+	return nil, nil
+}
+
+func GetGroupForAdd(args map[string]string) (interface{}, error) {
+	return nil, nil
+}
+
+func GetGroup(args map[string]string) (interface{}, error) {
+	return nil, nil
+}
+
+func UpdateGroup(args map[string]string, r *http.Request) (IDer, error) {
+	return nil, nil
+}
+
+func DeleteGroup(args map[string]string, r *http.Request) (IDer, error) {
+	return nil, nil
+}
+
+func AddGroup(args map[string]string, r *http.Request) (IDer, error) {
+	return nil, nil
+}

+ 20 - 0
orm/mappings.go

@@ -89,6 +89,17 @@ var (
 		"/api/administratives/{id}":        GetAdministrativeAll,
 		"/api/administratives/{id}/update": GetAdministrative,
 		"/api/administratives/add/":        GetNothing,
+
+		// Groups
+		"/groups":             GetGroupsAll,
+		"/groups/{id}":        GetGroupAll,
+		"/groups/{id}/update": GetGroupForUpdate,
+		"/groups/add/":        GetGroupForAdd,
+
+		"/api/groups":             GetGroupsAll,
+		"/api/groups/{id}":        GetGroupAll,
+		"/api/groups/{id}/update": GetGroup,
+		"/api/groups/add/":        GetNothing,
 	}
 
 	Post map[string]PostFn = map[string]PostFn{
@@ -165,5 +176,14 @@ var (
 		"/api/administratives/{id}/update": UpdateAdministrative,
 		"/api/administratives/{id}/delete": DeleteAdministrative,
 		"/api/administratives/add/":        AddAdministrative,
+
+		// Groups
+		"/groups/{id}/update": UpdateGroup,
+		"/groups/{id}/delete": DeleteGroup,
+		"/groups/add/":        AddGroup,
+
+		"/api/groups/{id}/update": UpdateGroup,
+		"/api/groups/{id}/delete": DeleteGroup,
+		"/api/groups/add/":        AddGroup,
 	}
 )

+ 1 - 0
orm/orm.go

@@ -77,6 +77,7 @@ func AutoMigrate() {
 		&Student{},
 		&Office{},
 		&Administrative{},
+		&Group{},
 	).Error; err != nil {
 		panic(err)
 	}

+ 3 - 2
templates/layout/base.html.tpl

@@ -42,8 +42,9 @@
            <li class="nav-item">
 	     <a class="nav-item nav-link" href="/administratives?{{query "tpl_layout" "base" "tpl_content" "administratives"}}">Amministrativi</a>
 	   </li>
-
-
+           <li class="nav-item">
+	     <a class="nav-item nav-link" href="/groups?{{query "tpl_layout" "base" "tpl_content" "groups"}}">Gruppi</a>
+	   </li>
 	  </ul>
 
 	  <ul class="nav navbar-nav navbar-right">