Update flag columns to BOOLEAN.

This commit is contained in:
takezoe
2013-06-21 13:24:58 +09:00
parent 44e53e05fd
commit 65eb89475a
16 changed files with 58 additions and 76 deletions

View File

@@ -2,7 +2,7 @@ CREATE TABLE ACCOUNT(
USER_NAME VARCHAR(100) NOT NULL, USER_NAME VARCHAR(100) NOT NULL,
MAIL_ADDRESS VARCHAR(100) NOT NULL, MAIL_ADDRESS VARCHAR(100) NOT NULL,
PASSWORD VARCHAR(20) NOT NULL, PASSWORD VARCHAR(20) NOT NULL,
USER_TYPE INT DEFAULT 0 NOT NULL, ADMINISTRATOR BOOLEAN NOT NULL,
URL VARCHAR(200), URL VARCHAR(200),
REGISTERED_DATE TIMESTAMP NOT NULL, REGISTERED_DATE TIMESTAMP NOT NULL,
UPDATED_DATE TIMESTAMP NOT NULL, UPDATED_DATE TIMESTAMP NOT NULL,
@@ -12,7 +12,7 @@ CREATE TABLE ACCOUNT(
CREATE TABLE REPOSITORY( CREATE TABLE REPOSITORY(
REPOSITORY_NAME VARCHAR(100) NOT NULL, REPOSITORY_NAME VARCHAR(100) NOT NULL,
USER_NAME VARCHAR(100) NOT NULL, USER_NAME VARCHAR(100) NOT NULL,
REPOSITORY_TYPE INT DEFAULT 0 NOT NULL, PRIVATE BOOLEAN NOT NULL,
DESCRIPTION TEXT, DESCRIPTION TEXT,
DEFAULT_BRANCH VARCHAR(100), DEFAULT_BRANCH VARCHAR(100),
REGISTERED_DATE TIMESTAMP NOT NULL, REGISTERED_DATE TIMESTAMP NOT NULL,
@@ -35,6 +35,7 @@ CREATE TABLE ISSUE(
ASSIGNED_USER_NAME VARCHAR(100), ASSIGNED_USER_NAME VARCHAR(100),
TITLE TEXT NOT NULL, TITLE TEXT NOT NULL,
CONTENT TEXT, CONTENT TEXT,
CLOSED BOOLEAN NOT NULL,
REGISTERED_DATE TIMESTAMP NOT NULL, REGISTERED_DATE TIMESTAMP NOT NULL,
UPDATED_DATE TIMESTAMP NOT NULL UPDATED_DATE TIMESTAMP NOT NULL
); );
@@ -113,7 +114,7 @@ INSERT INTO ACCOUNT (
USER_NAME, USER_NAME,
MAIL_ADDRESS, MAIL_ADDRESS,
PASSWORD, PASSWORD,
USER_TYPE, ADMINISTRATOR,
URL, URL,
REGISTERED_DATE, REGISTERED_DATE,
UPDATED_DATE, UPDATED_DATE,
@@ -122,7 +123,7 @@ INSERT INTO ACCOUNT (
'root', 'root',
'root@localhost', 'root@localhost',
'root', 'root',
1, true,
'https://github.com/takezoe/gitbucket', 'https://github.com/takezoe/gitbucket',
SYSDATE, SYSDATE,
SYSDATE, SYSDATE,

View File

@@ -12,12 +12,12 @@ class SettingsController extends SettingsControllerBase
trait SettingsControllerBase extends ControllerBase { trait SettingsControllerBase extends ControllerBase {
self: RepositoryService with AccountService with OwnerOnlyAuthenticator => self: RepositoryService with AccountService with OwnerOnlyAuthenticator =>
case class OptionsForm(description: Option[String], defaultBranch: String, repositoryType: Int) case class OptionsForm(description: Option[String], defaultBranch: String, isPrivate: Boolean)
val optionsForm = mapping( val optionsForm = mapping(
"description" -> trim(label("Description" , optional(text()))), "description" -> trim(label("Description" , optional(text()))),
"defaultBranch" -> trim(label("Default Branch" , text(required, maxlength(100)))), "defaultBranch" -> trim(label("Default Branch" , text(required, maxlength(100)))),
"repositoryType" -> trim(label("Repository Type", number())) "isPrivate" -> trim(label("Repository Type", boolean()))
)(OptionsForm.apply) )(OptionsForm.apply)
case class CollaboratorForm(userName: String) case class CollaboratorForm(userName: String)
@@ -57,7 +57,7 @@ trait SettingsControllerBase extends ControllerBase {
val repository = params("repository") val repository = params("repository")
// save repository options // save repository options
saveRepositoryOptions(owner, repository, form.description, form.defaultBranch, form.repositoryType) saveRepositoryOptions(owner, repository, form.description, form.defaultBranch, form.isPrivate)
redirect("%s/%s/settings/options".format(owner, repository)) redirect("%s/%s/settings/options".format(owner, repository))
}) })

View File

@@ -10,13 +10,13 @@ class UsersController extends UsersControllerBase with AccountService with Admin
trait UsersControllerBase extends ControllerBase { self: AccountService with AdminOnlyAuthenticator => trait UsersControllerBase extends ControllerBase { self: AccountService with AdminOnlyAuthenticator =>
// TODO ユーザ名の先頭に_は使えないようにする利用可能文字チェック // TODO ユーザ名の先頭に_は使えないようにする利用可能文字チェック
case class UserForm(userName: String, password: String, mailAddress: String, userType: Int, url: Option[String]) case class UserForm(userName: String, password: String, mailAddress: String, isAdmin: Boolean, url: Option[String])
val newForm = mapping( val newForm = mapping(
"userName" -> trim(label("Username" , text(required, maxlength(100), unique))), "userName" -> trim(label("Username" , text(required, maxlength(100), unique))),
"password" -> trim(label("Password" , text(required, maxlength(100)))), "password" -> trim(label("Password" , text(required, maxlength(100)))),
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))), "mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))),
"userType" -> trim(label("User Type" , number())), "isAdmin" -> trim(label("User Type" , boolean())),
"url" -> trim(label("URL" , optional(text(maxlength(200))))) "url" -> trim(label("URL" , optional(text(maxlength(200)))))
)(UserForm.apply) )(UserForm.apply)
@@ -24,7 +24,7 @@ trait UsersControllerBase extends ControllerBase { self: AccountService with Adm
"userName" -> trim(label("Username" , text())), "userName" -> trim(label("Username" , text())),
"password" -> trim(label("Password" , text(required, maxlength(100)))), "password" -> trim(label("Password" , text(required, maxlength(100)))),
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))), "mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))),
"userType" -> trim(label("User Type" , number())), "isAdmin" -> trim(label("User Type" , boolean())),
"url" -> trim(label("URL" , optional(text(maxlength(200))))) "url" -> trim(label("URL" , optional(text(maxlength(200)))))
)(UserForm.apply) )(UserForm.apply)
@@ -42,7 +42,7 @@ trait UsersControllerBase extends ControllerBase { self: AccountService with Adm
userName = form.userName, userName = form.userName,
password = form.password, password = form.password,
mailAddress = form.mailAddress, mailAddress = form.mailAddress,
userType = form.userType, isAdmin = form.isAdmin,
url = form.url, url = form.url,
registeredDate = currentDate, registeredDate = currentDate,
updatedDate = currentDate, updatedDate = currentDate,
@@ -62,7 +62,7 @@ trait UsersControllerBase extends ControllerBase { self: AccountService with Adm
updateAccount(getAccountByUserName(userName).get.copy( updateAccount(getAccountByUserName(userName).get.copy(
password = form.password, password = form.password,
mailAddress = form.mailAddress, mailAddress = form.mailAddress,
userType = form.userType, isAdmin = form.isAdmin,
url = form.url, url = form.url,
updatedDate = currentDate)) updatedDate = currentDate))

View File

@@ -193,7 +193,7 @@ trait WikiControllerBase extends ControllerBase {
def isWritable(owner: String, repository: String): Boolean = { def isWritable(owner: String, repository: String): Boolean = {
context.loginAccount match { context.loginAccount match {
case Some(a) if(a.userType == AccountService.Administrator) => true case Some(a) if(a.isAdmin) => true
case Some(a) if(a.userName == owner) => true case Some(a) if(a.userName == owner) => true
case Some(a) if(getCollaborators(owner, repository).contains(a.userName)) => true case Some(a) if(getCollaborators(owner, repository).contains(a.userName)) => true
case _ => false case _ => false

View File

@@ -6,12 +6,12 @@ object Accounts extends Table[Account]("ACCOUNT") {
def userName = column[String]("USER_NAME", O PrimaryKey) def userName = column[String]("USER_NAME", O PrimaryKey)
def mailAddress = column[String]("MAIL_ADDRESS") def mailAddress = column[String]("MAIL_ADDRESS")
def password = column[String]("PASSWORD") def password = column[String]("PASSWORD")
def userType = column[Int]("USER_TYPE") def isAdmin = column[Boolean]("ADMINISTRATOR")
def url = column[String]("URL") def url = column[String]("URL")
def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later
def updatedDate = column[java.sql.Date]("UPDATED_DATE") def updatedDate = column[java.sql.Date]("UPDATED_DATE")
def lastLoginDate = column[java.sql.Date]("LAST_LOGIN_DATE") def lastLoginDate = column[java.sql.Date]("LAST_LOGIN_DATE")
def * = userName ~ mailAddress ~ password ~ userType ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> (Account, Account.unapply _) def * = userName ~ mailAddress ~ password ~ isAdmin ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> (Account, Account.unapply _)
// def ins = userName ~ mailAddress ~ password ~ userType ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> ({ t => Account(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Account) => Some((o.userName, o.mailAddress, o.password, o.userType, o.url, o.registeredDate, o.updatedDate, o.lastLoginDate))}) // def ins = userName ~ mailAddress ~ password ~ userType ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> ({ t => Account(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Account) => Some((o.userName, o.mailAddress, o.password, o.userType, o.url, o.registeredDate, o.updatedDate, o.lastLoginDate))})
} }
@@ -19,7 +19,7 @@ case class Account(
userName: String, userName: String,
mailAddress: String, mailAddress: String,
password: String, password: String,
userType: Int, isAdmin: Boolean,
url: Option[String], url: Option[String],
registeredDate: java.sql.Date, registeredDate: java.sql.Date,
updatedDate: java.sql.Date, updatedDate: java.sql.Date,
@@ -29,8 +29,7 @@ case class Account(
class AccountDao { class AccountDao {
import Database.threadLocalSession import Database.threadLocalSession
// def insert(o: Account): Account = Accounts.ins returning Accounts.* insert o def insert(o: Account): Long = Accounts insert o
def insert(o: Account): Long = Accounts.* insert o
def select(key: String): Option[Account] = Query(Accounts) filter(_.userName is key.bind) firstOption def select(key: String): Option[Account] = Query(Accounts) filter(_.userName is key.bind) firstOption

View File

@@ -5,20 +5,20 @@ import scala.slick.driver.H2Driver.simple._
object Repositories extends Table[Repository]("REPOSITORY") { object Repositories extends Table[Repository]("REPOSITORY") {
def repositoryName= column[String]("REPOSITORY_NAME", O PrimaryKey) def repositoryName= column[String]("REPOSITORY_NAME", O PrimaryKey)
def userName = column[String]("USER_NAME", O PrimaryKey) def userName = column[String]("USER_NAME", O PrimaryKey)
def repositoryType = column[Int]("REPOSITORY_TYPE") // TODO should be sealed? def isPrivate = column[Boolean]("PRIVATE")
def description = column[String]("DESCRIPTION") def description = column[String]("DESCRIPTION")
def defaultBranch = column[String]("DEFAULT_BRANCH") def defaultBranch = column[String]("DEFAULT_BRANCH")
def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later
def updatedDate = column[java.sql.Date]("UPDATED_DATE") def updatedDate = column[java.sql.Date]("UPDATED_DATE")
def lastActivityDate = column[java.sql.Date]("LAST_ACTIVITY_DATE") def lastActivityDate = column[java.sql.Date]("LAST_ACTIVITY_DATE")
def * = repositoryName ~ userName ~ repositoryType ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _) def * = repositoryName ~ userName ~ isPrivate ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _)
// def ins = repositoryName ~ userName ~ repositoryType ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> ({ t => Project(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Project) => Some((o.projectName, o.userId, o.projectType, o.description, o.defaultBranch, o.registeredDate, o.updatedDate, o.lastActivityDate))}) // def ins = repositoryName ~ userName ~ repositoryType ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> ({ t => Project(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Project) => Some((o.projectName, o.userId, o.projectType, o.description, o.defaultBranch, o.registeredDate, o.updatedDate, o.lastActivityDate))})
} }
case class Repository( case class Repository(
repositoryName: String, repositoryName: String,
userName: String, userName: String,
repositoryType: Int, isPrivate: Boolean,
description: Option[String], description: Option[String],
defaultBranch: String, defaultBranch: String,
registeredDate: java.sql.Date, registeredDate: java.sql.Date,

View File

@@ -16,11 +16,11 @@ trait AccountService {
def updateAccount(account: Account): Unit = def updateAccount(account: Account): Unit =
Query(Accounts) Query(Accounts)
.filter { a => a.userName is account.userName.bind } .filter { a => a.userName is account.userName.bind }
.map { a => a.password ~ a.mailAddress ~ a.userType ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.? } .map { a => a.password ~ a.mailAddress ~ a.isAdmin ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.? }
.update ( .update (
account.password, account.password,
account.mailAddress, account.mailAddress,
account.userType, account.isAdmin,
account.url, account.url,
account.registeredDate, account.registeredDate,
account.updatedDate, account.updatedDate,
@@ -31,10 +31,3 @@ trait AccountService {
.update(new java.sql.Date(System.currentTimeMillis)) .update(new java.sql.Date(System.currentTimeMillis))
} }
object AccountService {
val Normal = 0
val Administrator = 1
}

View File

@@ -34,7 +34,7 @@ trait RepositoryService { self: AccountService =>
Repository( Repository(
repositoryName = repositoryName, repositoryName = repositoryName,
userName = userName, userName = userName,
repositoryType = Public, isPrivate = false,
description = description, description = description,
defaultBranch = "master", defaultBranch = "master",
registeredDate = currentDate, registeredDate = currentDate,
@@ -112,14 +112,14 @@ trait RepositoryService { self: AccountService =>
def getAccessibleRepositories(account: Option[Account], baseUrl: String): List[RepositoryInfo] = { def getAccessibleRepositories(account: Option[Account], baseUrl: String): List[RepositoryInfo] = {
account match { account match {
// for Administrators // for Administrators
case Some(x) if(x.userType == AccountService.Administrator) => { case Some(x) if(x.isAdmin) => {
(Query(Repositories) sortBy(_.lastActivityDate desc) list) map { repository => (Query(Repositories) sortBy(_.lastActivityDate desc) list) map { repository =>
val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl) val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl)
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags) RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags)
} }
} }
// for Normal Users // for Normal Users
case Some(x) if(x.userType == AccountService.Normal) => { case Some(x) if(!x.isAdmin) => {
// TODO only repositories registered as collaborator // TODO only repositories registered as collaborator
(Query(Repositories) sortBy(_.lastActivityDate desc) list) map { repository => (Query(Repositories) sortBy(_.lastActivityDate desc) list) map { repository =>
val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl) val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl)
@@ -128,7 +128,7 @@ trait RepositoryService { self: AccountService =>
} }
// for Guests // for Guests
case None => { case None => {
(Query(Repositories) filter(_.repositoryType is Public.bind) sortBy(_.lastActivityDate desc) list) map { repository => (Query(Repositories) filter(_.isPrivate is false.bind) sortBy(_.lastActivityDate desc) list) map { repository =>
val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl) val repositoryInfo = JGitUtil.getRepositoryInfo(repository.userName, repository.repositoryName, baseUrl)
RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags) RepositoryInfo(repositoryInfo.owner, repositoryInfo.name, repositoryInfo.url, repository, repositoryInfo.branchList, repositoryInfo.tags)
} }
@@ -149,11 +149,11 @@ trait RepositoryService { self: AccountService =>
* Save repository options. * Save repository options.
*/ */
def saveRepositoryOptions(userName: String, repositoryName: String, def saveRepositoryOptions(userName: String, repositoryName: String,
description: Option[String], defaultBranch: String, repositoryType: Int): Unit = description: Option[String], defaultBranch: String, isPrivate: Boolean): Unit =
Query(Repositories) Query(Repositories)
.filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) } .filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) }
.map { r => r.description.? ~ r.defaultBranch ~ r.repositoryType ~ r.updatedDate } .map { r => r.description.? ~ r.defaultBranch ~ r.isPrivate ~ r.updatedDate }
.update (description, defaultBranch, repositoryType, new java.sql.Date(System.currentTimeMillis)) .update (description, defaultBranch, isPrivate, new java.sql.Date(System.currentTimeMillis))
/** /**
* Add collaborator to the repository. * Add collaborator to the repository.
@@ -194,8 +194,6 @@ trait RepositoryService { self: AccountService =>
object RepositoryService { object RepositoryService {
val Public = 0
val Private = 1
case class RepositoryInfo(owner: String, name: String, url: String, repository: Repository, branchList: List[String], tags: List[util.JGitUtil.TagInfo]) case class RepositoryInfo(owner: String, name: String, url: String, repository: Repository, branchList: List[String], tags: List[util.JGitUtil.TagInfo])
} }

View File

@@ -27,8 +27,7 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
getRepository(repositoryOwner, repositoryName.replaceFirst("\\.wiki", ""), "") match { getRepository(repositoryOwner, repositoryName.replaceFirst("\\.wiki", ""), "") match {
case Some(repository) => { case Some(repository) => {
if(!request.getRequestURI.endsWith("/git-receive-pack") && if(!request.getRequestURI.endsWith("/git-receive-pack") && !repository.repository.isPrivate){
repository.repository.repositoryType == RepositoryService.Public){
chain.doFilter(req, res) chain.doFilter(req, res)
} else { } else {
request.getHeader("Authorization") match { request.getHeader("Authorization") match {
@@ -56,7 +55,7 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
private def isWritableUser(username: String, password: String, repository: RepositoryService.RepositoryInfo): Boolean = { private def isWritableUser(username: String, password: String, repository: RepositoryService.RepositoryInfo): Boolean = {
getAccountByUserName(username) match { getAccountByUserName(username) match {
case Some(account) if(account.password == password) => { case Some(account) if(account.password == password) => {
(account.userType == AccountService.Administrator // administrator (account.isAdmin // administrator
|| account.userName == repository.owner // repository owner || account.userName == repository.owner // repository owner
|| getCollaborators(repository.owner, repository.name).contains(account.userName)) // collaborator || getCollaborators(repository.owner, repository.name).contains(account.userName)) // collaborator
} }

View File

@@ -14,7 +14,7 @@ trait OwnerOnlyAuthenticator { self: ControllerBase =>
private def authenticate(action: => Any) = { private def authenticate(action: => Any) = {
{ {
context.loginAccount match { context.loginAccount match {
case Some(x) if(x.userType == AccountService.Administrator) => action case Some(x) if(x.isAdmin) => action
case Some(x) if(request.getRequestURI.split("/")(1) == x.userName) => action case Some(x) if(request.getRequestURI.split("/")(1) == x.userName) => action
case _ => Unauthorized() case _ => Unauthorized()
} }
@@ -50,7 +50,7 @@ trait AdminOnlyAuthenticator { self: ControllerBase =>
private def authenticate(action: => Any) = { private def authenticate(action: => Any) = {
{ {
context.loginAccount match { context.loginAccount match {
case Some(x) if(x.userType == AccountService.Administrator) => action case Some(x) if(x.isAdmin) => action
case _ => Unauthorized() case _ => Unauthorized()
} }
} }
@@ -67,7 +67,7 @@ trait WritableRepositoryAuthenticator { self: ControllerBase with RepositoryServ
private def authenticate(action: => Any) = { private def authenticate(action: => Any) = {
val paths = request.getRequestURI.split("/") val paths = request.getRequestURI.split("/")
context.loginAccount match { context.loginAccount match {
case Some(x) if(x.userType == AccountService.Administrator) => action case Some(x) if(x.isAdmin) => action
case Some(x) if(paths(1) == x.userName) => action case Some(x) if(paths(1) == x.userName) => action
case Some(x) if(getCollaborators(paths(1), paths(2)).contains(x.userName)) => action case Some(x) if(getCollaborators(paths(1), paths(2)).contains(x.userName)) => action
case _ => Unauthorized() case _ => Unauthorized()
@@ -88,11 +88,11 @@ trait ReadableRepositoryAuthenticator { self: ControllerBase with RepositoryServ
getRepository(paths(1), paths(2), baseUrl) match { getRepository(paths(1), paths(2), baseUrl) match {
case None => NotFound() case None => NotFound()
case Some(repository) => case Some(repository) =>
if(repository.repository.repositoryType == RepositoryService.Public){ if(!repository.repository.isPrivate){
action action
} else { } else {
context.loginAccount match { context.loginAccount match {
case Some(x) if(x.userType == AccountService.Administrator) => action case Some(x) if(x.isAdmin) => action
case Some(x) if(paths(1) == x.userName) => action case Some(x) if(paths(1) == x.userName) => action
case Some(x) if(getCollaborators(paths(1), paths(2)).contains(x.userName)) => action case Some(x) if(getCollaborators(paths(1), paths(2)).contains(x.userName)) => action
case _ => Unauthorized() case _ => Unauthorized()

View File

@@ -1,6 +1,5 @@
@(account: model.Account, repositories: List[service.RepositoryService.RepositoryInfo])(implicit context: app.Context) @(account: model.Account, repositories: List[service.RepositoryService.RepositoryInfo])(implicit context: app.Context)
@import context._ @import context._
@import service.RepositoryService._
@html.main(account.userName){ @html.main(account.userName){
<div class="container-fluid"> <div class="container-fluid">
<div class="row-fluid"> <div class="row-fluid">
@@ -33,7 +32,7 @@
<a href="@path/@repository.owner">@repository.owner</a> <a href="@path/@repository.owner">@repository.owner</a>
/ /
<a href="@path/@repository.owner/@repository.name">@repository.name</a> <a href="@path/@repository.owner/@repository.name">@repository.name</a>
@if(repository.repository.repositoryType == Private){ @if(repository.repository.isPrivate){
<i class="icon-lock"></i> <i class="icon-lock"></i>
} }
</div> </div>

View File

@@ -1,6 +1,5 @@
@(account: Option[model.Account])(implicit context: app.Context) @(account: Option[model.Account])(implicit context: app.Context)
@import context._ @import context._
@import service.AccountService._
@html.main(if(account.isEmpty) "New User" else "Update User"){ @html.main(if(account.isEmpty) "New User" else "Update User"){
<form method="POST" action="@if(account.isEmpty){@path/admin/users/_new} else {@path/admin/users/@account.get.userName/_edit}" validate="true"> <form method="POST" action="@if(account.isEmpty){@path/admin/users/_new} else {@path/admin/users/@account.get.userName/_edit}" validate="true">
<fieldset> <fieldset>
@@ -21,10 +20,10 @@
<fieldset> <fieldset>
<label><strong>User Type</strong></label> <label><strong>User Type</strong></label>
<label for="userType_Normal"> <label for="userType_Normal">
<input type="radio" name="userType" id="userType_Normal" value="@Normal"@if(account.isEmpty || account.get.userType==Normal){ checked}/> Normal <input type="radio" name="isAdmin" id="userType_Normal" value="false"@if(account.isEmpty || !account.get.isAdmin){ checked}/> Normal
</label> </label>
<label for="userType_Admin"> <label for="userType_Admin">
<input type="radio" name="userType" id="userType_Admin" value="@Administrator"@if(account.isDefined && account.get.userType==Administrator){ checked}/> Administrator <input type="radio" name="isAdmin" id="userType_Admin" value="true"@if(account.isDefined && account.get.isAdmin){ checked}/> Administrator
</label> </label>
</fieldset> </fieldset>
<fieldset> <fieldset>

View File

@@ -1,6 +1,5 @@
@(users: List[model.Account])(implicit context: app.Context) @(users: List[model.Account])(implicit context: app.Context)
@import context._ @import context._
@import service.AccountService._
@html.main("Manage Users"){ @html.main("Manage Users"){
<div style="text-align: right; margin-bottom: 4px;"> <div style="text-align: right; margin-bottom: 4px;">
<a href="@path/admin/users/_new" class="btn">New User</a> <a href="@path/admin/users/_new" class="btn">New User</a>
@@ -20,11 +19,10 @@
<td><a href="@path/admin/users/@account.userName/_edit">@account.userName</a></td> <td><a href="@path/admin/users/@account.userName/_edit">@account.userName</a></td>
<td>@account.mailAddress</td> <td>@account.mailAddress</td>
<td> <td>
@if(account.userType == Normal){ @if(account.isAdmin){
Normal
}
@if(account.userType == Administrator){
Administrator Administrator
} else {
Normal
} }
</td> </td>
<td>@account.url</td> <td>@account.url</td>

View File

@@ -1,10 +1,8 @@
@(active: String, repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) @(active: String, repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
@import context._ @import context._
@import service.AccountService._
@import service.RepositoryService._
<div class="head"> <div class="head">
<a href="@path/@repository.owner">@repository.owner</a> / <a href="@path/@repository.owner/@repository.name">@repository.name</a> <a href="@path/@repository.owner">@repository.owner</a> / <a href="@path/@repository.owner/@repository.name">@repository.name</a>
@if(repository.repository.repositoryType == Private){ @if(repository.repository.isPrivate){
<i class="icon-lock"></i> <i class="icon-lock"></i>
} }
</div> </div>
@@ -19,7 +17,7 @@
<th class="box-header@if(active=="wiki"){ active}"> <th class="box-header@if(active=="wiki"){ active}">
<a href="@path/@repository.owner/@repository.name/wiki">Wiki</a> <a href="@path/@repository.owner/@repository.name/wiki">Wiki</a>
</th> </th>
@if(loginAccount.isDefined && (loginAccount.get.userType == Administrator || loginAccount.get.userName == repository.owner)){ @if(loginAccount.isDefined && (loginAccount.get.isAdmin || loginAccount.get.userName == repository.owner)){
<th class="box-header@if(active=="settings"){ active}"> <th class="box-header@if(active=="settings"){ active}">
<a href="@path/@repository.owner/@repository.name/settings">Settings</a> <a href="@path/@repository.owner/@repository.name/settings">Settings</a>
</th> </th>

View File

@@ -1,6 +1,5 @@
@(repositories: List[service.RepositoryService.RepositoryInfo])(implicit context: app.Context) @(repositories: List[service.RepositoryService.RepositoryInfo])(implicit context: app.Context)
@import context._ @import context._
@import service.RepositoryService._
@main("GitBucket"){ @main("GitBucket"){
<h3>Recent updated repositories</h3> <h3>Recent updated repositories</h3>
@repositories.map { repository => @repositories.map { repository =>
@@ -9,7 +8,7 @@
<a href="@path/@repository.owner">@repository.owner</a> <a href="@path/@repository.owner">@repository.owner</a>
/ /
<a href="@path/@repository.owner/@repository.name">@repository.name</a> <a href="@path/@repository.owner/@repository.name">@repository.name</a>
@if(repository.repository.repositoryType == Private){ @if(repository.repository.isPrivate){
<i class="icon-lock"></i> <i class="icon-lock"></i>
} }
</div> </div>

View File

@@ -1,6 +1,5 @@
@(repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) @(repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
@import context._ @import context._
@import service.RepositoryService._
@html.main("Settings"){ @html.main("Settings"){
@html.header("settings", repository) @html.header("settings", repository)
@menu("options", repository){ @menu("options", repository){
@@ -25,11 +24,11 @@
<fieldset> <fieldset>
<label><strong>Repository Type</strong></label> <label><strong>Repository Type</strong></label>
<label> <label>
<input type="radio" name="repositoryType" value="@Public"@if(repository.repository.repositoryType==Public){ checked}> <input type="radio" name="isPrivate" value="false"@if(!repository.repository.isPrivate){ checked}>
<strong>Public</strong> - All users and guests can read this repository. <strong>Public</strong> - All users and guests can read this repository.
</label> </label>
<label> <label>
<input type="radio" name="repositoryType" value="@Private"@if(repository.repository.repositoryType==Private){ checked}> <input type="radio" name="isPrivate" value="true"@if(repository.repository.isPrivate){ checked}>
<strong>Private</strong> - Only collaborators can read this repository. <strong>Private</strong> - Only collaborators can read this repository.
</label> </label>
</fieldset> </fieldset>