diff --git a/models/repo.go b/models/repo.go index 1228a79ba..f99e909ae 100755 --- a/models/repo.go +++ b/models/repo.go @@ -1105,6 +1105,12 @@ func CreateRepository(ctx DBContext, doer, u *User, repo *Repository) (err error Type: tp, Config: &CloudBrainConfig{EnableCloudBrain: true}, }) + } else if tp == UnitTypeBlockChain { + units = append(units, RepoUnit{ + RepoID: repo.ID, + Type: tp, + Config: &BlockChainConfig{EnableBlockChain: true}, + }) } else { units = append(units, RepoUnit{ RepoID: repo.ID, diff --git a/models/repo_unit.go b/models/repo_unit.go old mode 100644 new mode 100755 index a0e7a2f76..518c4b979 --- a/models/repo_unit.go +++ b/models/repo_unit.go @@ -141,6 +141,20 @@ func (cfg *CloudBrainConfig) ToDB() ([]byte, error) { return json.Marshal(cfg) } +type BlockChainConfig struct { + EnableBlockChain bool +} + +// FromDB fills up a CloudBrainConfig from serialized format. +func (cfg *BlockChainConfig) FromDB(bs []byte) error { + return json.Unmarshal(bs, &cfg) +} + +// ToDB exports a CloudBrainConfig to a serialized format. +func (cfg *BlockChainConfig) ToDB() ([]byte, error) { + return json.Marshal(cfg) +} + // BeforeSet is invoked from XORM before setting the value of a field of this object. func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) { switch colName { @@ -160,6 +174,8 @@ func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) { r.Config = new(DatasetConfig) case UnitTypeCloudBrain: r.Config = new(CloudBrainConfig) + case UnitTypeBlockChain: + r.Config = new(BlockChainConfig) default: panic("unrecognized repo unit type: " + com.ToStr(*val)) } diff --git a/routers/repo/blockchain.go b/routers/repo/blockchain.go index 9f2e9f2d4..33129d7e4 100755 --- a/routers/repo/blockchain.go +++ b/routers/repo/blockchain.go @@ -24,16 +24,7 @@ const ( tplBlockChainIndex base.TplName = "repo/blockchain/index" ) -// MustEnableDataset check if repository enable internal cb -func MustEnableBlockChain(ctx *context.Context) { - if !ctx.Repo.CanRead(models.UnitTypeBlockChain) { - ctx.NotFound("MustEnableBlockChain", nil) - return - } -} - func BlockChainIndex(ctx *context.Context) { - MustEnableBlockChain(ctx) repo := ctx.Repo.Repository if repo.ContractAddress == "" || ctx.User.PublicKey == ""{ log.Error("the repo(%d) or the user(%d) has not been initialized in block_chain", repo.RepoID, ctx.User.ID) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 67186ccd2..8831e20a5 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -568,7 +568,7 @@ func RegisterRoutes(m *macaron.Macaron) { reqRepoDatasetWriter := context.RequireRepoWriter(models.UnitTypeDatasets) reqRepoCloudBrainReader := context.RequireRepoReader(models.UnitTypeCloudBrain) reqRepoCloudBrainWriter := context.RequireRepoWriter(models.UnitTypeCloudBrain) - reqRepoBlockChainReader := context.RequireRepoReader(models.UnitTypeBlockChain) + //reqRepoBlockChainReader := context.RequireRepoReader(models.UnitTypeBlockChain) //reqRepoBlockChainWriter := context.RequireRepoWriter(models.UnitTypeBlockChain) // ***** START: Organization ***** @@ -914,7 +914,7 @@ func RegisterRoutes(m *macaron.Macaron) { }, context.RepoRef()) m.Group("/blockchain", func() { - m.Get("", reqRepoBlockChainReader, repo.BlockChainIndex) + m.Get("", repo.BlockChainIndex) }, context.RepoRef()) m.Group("/wiki", func() { diff --git a/templates/repo/blockchain/index.tmpl b/templates/repo/blockchain/index.tmpl index a68381b01..3ce0f0e8b 100755 --- a/templates/repo/blockchain/index.tmpl +++ b/templates/repo/blockchain/index.tmpl @@ -12,101 +12,9 @@
- 212 + {{.balance}}
- - -
- - -
-
-
- - -
-
-
-
-
- -
-
-
- - -
- {{range .Tasks}} -
-
- - -
- {{svg "octicon-tasklist" 16}} - 项目名字《待补充》 - -
- - -
- 余额:待补充 -
- - -
- {{svg "octicon-flame" 16}} {{TimeSinceUnix .CreatedUnix $.Lang}} -
- - -
- - - 查看 - - -
- - -
- -
- - -
-
-
- {{$.CsrfTokenHtml}} - 删除 -
-
-
- - -
- -
- -
-
- -
- -
-
-
- + {{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 938937df5..c21a50c4e 100755 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -148,8 +148,6 @@ {{svg "octicon-balance" 16}} {{.i18n.Tr "repo.balance"}} - - {{template "custom/extra_tabs" .}}