summaryrefslogtreecommitdiffstats
path: root/models/models.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-02-14 22:20:57 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-02-14 22:20:57 +0800
commit237193ef2a58d890d50e96fcc99481849c42dca9 (patch)
tree3418b87d6f631abb15678bb32dc897ba7a4dcd18 /models/models.go
parenta30e5bcaf83a82f5f7d1c89a6f9f7e52036d74af (diff)
downloadgitea-237193ef2a58d890d50e96fcc99481849c42dca9.tar.gz
gitea-237193ef2a58d890d50e96fcc99481849c42dca9.zip
add user models
Diffstat (limited to 'models/models.go')
-rw-r--r--models/models.go75
1 files changed, 25 insertions, 50 deletions
diff --git a/models/models.go b/models/models.go
index d5a8c8cf5c..bddece474d 100644
--- a/models/models.go
+++ b/models/models.go
@@ -5,67 +5,42 @@
package models
import (
- "os"
- "path/filepath"
- "github.com/lunny/xorm"
+ "time"
- git "github.com/libgit2/git2go"
+ "github.com/lunny/xorm"
)
-const (
- UserRepo = iota
- OrgRepo
+var (
+ // orm
+ orm *xorm.Engine
+ // repository root path
+ root string
)
-type User struct {
- Id int64
- Name string `xorm:"unique"`
+type PublicKey struct {
+ Id int64
+ Name string `xorm:"unique not null"`
+ Content string `xorm:"text not null"`
+ Created time.Time `xorm:"created"`
+ Updated time.Time `xorm:"updated"`
}
-type Org struct {
- Id int64
+type Members struct {
+ Id int64
+ OrgId int64 `xorm:"unique(s) index"`
+ UserId int64 `xorm:"unique(s)"`
}
-type Repo struct {
- Id int64
- OwnerId int64 `xorm:"unique(s)"`
- Type int `xorm:"unique(s)"`
- Name string `xorm:"unique(s)"`
+type Issue struct {
+ Id int64
+ RepoId int64 `xorm:"index"`
+ PosterId int64
}
-var (
- orm *xorm.Engine
-)
-
-//
-// create a repository for a user or orgnaziation
-//
-func CreateUserRepository(root string, user *User, reposName string) error {
- p := filepath.Join(root, user.Name)
- os.MkdirAll(p, os.ModePerm)
- f := filepath.Join(p, reposName)
- _, err := git.InitRepository(f, false)
- if err != nil {
- return err
- }
-
- repo := Repo{OwnerId: user.Id, Type: UserRepo, Name: reposName}
- _, err = orm.Insert(&repo)
- if err != nil {
- os.RemoveAll(f)
- }
- return err
+type PullRequest struct {
+ Id int64
}
-//
-// delete a repository for a user or orgnaztion
-//
-func DeleteUserRepository(root string, user *User, reposName string) error {
- err := os.RemoveAll(filepath.Join(root, user.Name, reposName))
- if err != nil {
- return err
- }
-
- _, err = orm.Delete(&Repo{OwnerId: user.Id, Type: UserRepo, Name: reposName})
- return err
+type Comment struct {
+ Id int64
}