This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'jquery', | |
'underscore', | |
'backbone', | |
'text!templates/athelete/atheleteForm.html' | |
'i18n!nls/atheleteLabel' | |
], function($, _, Backbone, atheleteForm, atheleteLabel ){ | |
var AtheleteForm = Backbone.View.extend({ | |
el: "#athleteForm", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Contents of js/nls/atheleteLabel.js | |
define({ | |
'root': { | |
NAME : 'Name', | |
... | |
}, | |
'fr-fr': true | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Contents of js/nls/fr/atheleteLabel.js | |
define({ | |
NAME : 'Nom', | |
... | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Service Backbone save(); | |
* @param id | |
*/ | |
public void create(){ | |
JSONDeserializer<Athelete>reportDeserializer = new JSONDeserializer<Athelete>().use( null, Athelete.class ); | |
String json = params.get("body"); | |
Athelete athelete = reportDeserializer.deserialize(json); | |
athelete.save(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.api.db._ | |
import play.api.Play.current | |
import java.sql.Date | |
import scala.slick.driver.PostgresDriver.simple._ | |
import play.Logger | |
import scalaz.Failure | |
import scala.slick.lifted.Projection | |
import Users._ | |
import scala.slick.lifted.BaseTypeMapper | |
import scala.slick.driver.BasicProfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Article(id: Option[Long] = None, | |
name: String, | |
body: Option[String], // this is the body in edit | |
userID: Long, | |
created: Date, | |
category: String, | |
published: Boolean = false, | |
displayOrder: Int = -1, | |
publishedBody: Option[String] // body as published | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class ArticleId(id: Long) | |
case class ArticleForDisplay(id: Option[Long] = None, | |
publishedBody: Option[String], | |
userID: Long, | |
created: Date, | |
category: String, | |
published: Boolean) | |
case class ArticleForCreation(name: String, body: Option[String], category: ArticleCategory, published: Boolean = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Articles.update(valid) match { | |
case Success(a) => { | |
cache.Cache.remove("blog") | |
Ok(Json.toJson(ArticleId(valid.id))) | |
} | |
case Failure(e) => { | |
Logger.error("update error:", e) | |
BadRequest(Json.toJson(Map("error" -> e.getMessage()))) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ArticleTable = new Table[Article]("Article") { | |
def id = column[Long]("id", O.PrimaryKey, O.AutoInc) | |
def name = column[String]("name") | |
def body = column[Option[String]]("body") | |
def publishedBody = column[Option[String]]("publishedBody") | |
def userID = column[Long]("user_Id") | |
def created = column[Date]("created") | |
def category = column[String]("category") | |
def published = column[Boolean]("published") | |
def displayOrder = column[Int]("displayOrder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create(userId: Long, articleForCreation: ArticleForCreation): Try[ArticleId] = database.withSession { implicit db: Session => | |
Try( | |
ArticleId( | |
ArticleTable.forInsert.insert( | |
Article(None, | |
articleForCreation.name, | |
articleForCreation.body, | |
userId, | |
new java.sql.Date(System.currentTimeMillis()), | |
articleForCreation.category.toString(), |
OlderNewer