mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 19:16:53 +00:00
Privelege Admin page leads directly to displaying the list of existing privileges
This commit is contained in:
parent
6ae99e0539
commit
7dcc788503
@ -1,5 +1,6 @@
|
||||
package code.model
|
||||
|
||||
import com.mongodb.QueryBuilder
|
||||
import net.liftweb.mongodb.JsonObjectMeta
|
||||
import net.liftweb.mongodb.JsonObject
|
||||
import net.liftweb.mongodb.record.MongoMetaRecord
|
||||
@ -28,6 +29,16 @@ class Account extends MongoRecord[Account] with ObjectIdPk[Account]{
|
||||
protected object bank extends BsonRecordField(this, OBPBank)
|
||||
object otherAccounts extends BsonRecordListField(this, OtherAccount)
|
||||
|
||||
def allEnvelopes : List[OBPEnvelope] = {
|
||||
//TODO: This should use ids instead of just the holder name
|
||||
//TODO : Also, due to some string hardcoding where we used "Music Pictures Limited" instead of
|
||||
// what we get from our actual bank account ("MUSIC PICTURES LIMITED"), we have to make it
|
||||
// upper case. This all needs to be revamped once we support multiple accounts, so despite being
|
||||
// incredibly ugly, it should be okay temporarily
|
||||
val qry = QueryBuilder.start("obp_transaction.this_account.holder").is(holder.get.toUpperCase()).get
|
||||
OBPEnvelope.findAll(qry)
|
||||
}
|
||||
|
||||
def getUnmediatedOtherAccountUrl(user: String, otherAccountHolder: String) : Box[String] = {
|
||||
for{
|
||||
o <- otherAccounts.get.find(acc=> {
|
||||
|
||||
@ -411,19 +411,19 @@ class OBPAccount private() extends BsonRecord[OBPAccount]{
|
||||
case _ => Empty
|
||||
}
|
||||
}
|
||||
//JString(mediated_holder(user) getOrElse ("---")
|
||||
//JString(mediated_holder(user) getOrElse ("")
|
||||
def asMediatedJValue(user: String) : JObject = {
|
||||
val h = mediated_holder(user)
|
||||
JObject(List( JField("holder",
|
||||
JObject(List(
|
||||
JField("holder", JString(h._1.getOrElse("---"))),
|
||||
JField("holder", JString(h._1.getOrElse(""))),
|
||||
JField("alias", JString(h._2 match{
|
||||
case Full(OBPAccount.APublicAlias) => "public"
|
||||
case Full(OBPAccount.APrivateAlias) => "private"
|
||||
case _ => "no"
|
||||
}))))),
|
||||
JField("number", JString(mediated_number(user) getOrElse "---")),
|
||||
JField("kind", JString(mediated_kind(user) getOrElse "---")),
|
||||
JField("number", JString(mediated_number(user) getOrElse "")),
|
||||
JField("kind", JString(mediated_kind(user) getOrElse "")),
|
||||
JField("bank", bank.get.asMediatedJValue(user))))
|
||||
}
|
||||
}
|
||||
@ -475,9 +475,9 @@ class OBPBank private() extends BsonRecord[OBPBank]{
|
||||
}
|
||||
|
||||
def asMediatedJValue(user: String) : JObject = {
|
||||
JObject(List( JField("IBAN", JString(mediated_IBAN(user) getOrElse "---")),
|
||||
JField("national_identifier", JString(mediated_national_identifier(user) getOrElse "---")),
|
||||
JField("name", JString(mediated_name(user) getOrElse "---"))))
|
||||
JObject(List( JField("IBAN", JString(mediated_IBAN(user) getOrElse "")),
|
||||
JField("national_identifier", JString(mediated_national_identifier(user) getOrElse "")),
|
||||
JField("name", JString(mediated_name(user) getOrElse ""))))
|
||||
}
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@ class OBPDetails private() extends BsonRecord[OBPDetails]{
|
||||
def formatDate(date : Box[Date]) : String = {
|
||||
date match{
|
||||
case Full(d) => OBPDetails.formats.dateFormat.format(d)
|
||||
case _ => "---"
|
||||
case _ => ""
|
||||
}
|
||||
}
|
||||
|
||||
@ -540,11 +540,11 @@ class OBPDetails private() extends BsonRecord[OBPDetails]{
|
||||
}
|
||||
|
||||
def asMediatedJValue(user: String) : JObject = {
|
||||
JObject(List( JField("type_en", JString(mediated_type_en(user) getOrElse "---")),
|
||||
JField("type_de", JString(mediated_type_de(user) getOrElse "---")),
|
||||
JObject(List( JField("type_en", JString(mediated_type_en(user) getOrElse "")),
|
||||
JField("type_de", JString(mediated_type_de(user) getOrElse "")),
|
||||
JField("posted", JString(formatDate(mediated_posted(user)))),
|
||||
JField("completed", JString(formatDate(mediated_completed(user)))),
|
||||
JField("other_data", JString(mediated_other_data(user) getOrElse "---")),
|
||||
JField("other_data", JString(mediated_other_data(user) getOrElse "")),
|
||||
JField("new_balance", new_balance.get.asMediatedJValue(user)),
|
||||
JField("value", value.get.asMediatedJValue(user))))
|
||||
}
|
||||
@ -588,8 +588,8 @@ class OBPBalance private() extends BsonRecord[OBPBalance]{
|
||||
}
|
||||
|
||||
def asMediatedJValue(user: String) : JObject = {
|
||||
JObject(List( JField("currency", JString(mediated_currency(user) getOrElse "---")),
|
||||
JField("amount", JString(mediated_amount(user) getOrElse "---"))))
|
||||
JObject(List( JField("currency", JString(mediated_currency(user) getOrElse "")),
|
||||
JField("amount", JString(mediated_amount(user) getOrElse ""))))
|
||||
}
|
||||
}
|
||||
|
||||
@ -618,8 +618,8 @@ class OBPValue private() extends BsonRecord[OBPValue]{
|
||||
}
|
||||
|
||||
def asMediatedJValue(user: String) : JObject = {
|
||||
JObject(List( JField("currency", JString(mediated_currency(user) getOrElse "---")),
|
||||
JField("amount", JString(mediated_amount(user) getOrElse "---"))))
|
||||
JObject(List( JField("currency", JString(mediated_currency(user) getOrElse "")),
|
||||
JField("amount", JString(mediated_amount(user) getOrElse ""))))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -161,6 +161,9 @@ object Privilege extends Privilege with LongKeyedMetaMapper[Privilege] with CRUD
|
||||
override def displayName = "Privilege"
|
||||
override def showAllMenuLocParams = LocGroup("admin") :: Nil
|
||||
override def createMenuLocParams = LocGroup("admin") :: Nil
|
||||
override def fieldsForDisplay = super.fieldsForDisplay -- List(createdAt)
|
||||
override def fieldsForEditing = super.fieldsForEditing -- List(createdAt, updatedAt)
|
||||
|
||||
def showAll = doCrudAll(_)
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,6 @@ object OBPRest extends RestHelper with Loggable {
|
||||
} ' http://localhost:8080/api/transactions
|
||||
*/
|
||||
case "api" :: "transactions" :: Nil JsonPost json => {
|
||||
|
||||
val rawEnvelopes = json._1.children
|
||||
|
||||
val envelopes = rawEnvelopes.map(e => {
|
||||
@ -151,14 +150,25 @@ object OBPRest extends RestHelper with Loggable {
|
||||
//This is for demo purposes only, as it's showing every single transaction rather than everything tesobe specific. This will need
|
||||
//to be completely reworked.
|
||||
case "api" :: "accounts" :: "tesobe" :: accessLevel :: Nil JsonGet _ => {
|
||||
val allEnvelopes = OBPEnvelope.findAll(QueryBuilder.start().get)
|
||||
|
||||
val allEnvelopes = OBPEnvelope.findAll(QueryBuilder.start().get)
|
||||
|
||||
val envelopeJson = allEnvelopes.map(envelope => envelope.asMediatedJValue(accessLevel))
|
||||
|
||||
|
||||
JsonResponse(envelopeJson)
|
||||
}
|
||||
|
||||
//A work in progress to support a better authenticated API call
|
||||
//TODO: Remove access level from parameters list and get if from User/oauth/something similar
|
||||
case "api" :: "accounts" :: accountID :: accessLevel :: Nil JsonGet _ => {
|
||||
|
||||
for{
|
||||
account <- Account.find(accountID)
|
||||
} yield {
|
||||
val envelopeJson = account.allEnvelopes.map(envelope => envelope.asMediatedJValue(accessLevel))
|
||||
JsonResponse(envelopeJson)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,13 +33,21 @@ Open Bank Project (http://www.openbankproject.com)
|
||||
<body class="lift:content_id=main">
|
||||
<div id="main" class="lift:surround?with=default;at=content">
|
||||
|
||||
<div id="admin_links">
|
||||
<div class="lift:PrivilegeAdmin.createPrivileges">
|
||||
<a class="navlink" href="#">Create Privilege</a>
|
||||
</div>
|
||||
|
||||
<div class="lift:PrivilegeAdmin.listPrivileges">
|
||||
|
||||
</div>
|
||||
|
||||
<!-- <div id="admin_links">
|
||||
<ul>
|
||||
<li class="lift:Nav.group?group=admin navitem">
|
||||
<a class="navlink" href="#">Link name. Has class "selected" if it's the current page.</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user