Working display of the opencorporates url

This commit is contained in:
Everett Sochowski 2012-03-12 13:46:39 +01:00
parent d2a5f2da4d
commit 13837515fa
3 changed files with 18 additions and 15 deletions

View File

@ -102,6 +102,13 @@ class Account extends MongoRecord[Account] with ObjectIdPk[Account]{
}
}
def getUnmediatedOpenCorporatesUrl(user: String, otherAccountHolder: String) : Box[String] = {
for{
o <- otherAccounts.get.find(acc=> {
acc.holder.get.equals(otherAccountHolder)
})
} yield o.openCorporatesUrl.get
}
}
object Account extends Account with MongoMetaRecord[Account]

View File

@ -41,11 +41,7 @@ class Management {
val otherAcc = getMostUpToDateOtherAccount(holder)
if(otherAcc.isDefined){
val newOtherAcc = alterOtherAccount(otherAcc.get, currentValue)
val otherAccsSize = currentAccount.otherAccounts.get.size
val otherAccHolders = currentAccount.otherAccounts.get.map(_.holder.get)
val newOtherAccs = currentAccount.otherAccounts.get -- List(otherAcc.get) ++ List(newOtherAcc)
val newOtherAccHolders = newOtherAccs.map(_.holder.get)
val newOtherAccsSize = newOtherAccs.size
currentAccount.otherAccounts(newOtherAccs).save
}
@ -94,7 +90,7 @@ class Management {
".private_alias_name *" #> editablePrivateAlias(other.privateAlias.get, other.holder.get) &
".more_info *" #> editableMoreInfo(other.moreInfo.get, other.holder.get) &
".website_url *" #> editableUrl(other.url.get, other.holder.get) &
".open_corporates_url *" #> editableUrl(other.openCorporatesUrl.get, other.holder.get)).apply(xhtml)
".open_corporates_url *" #> editableOpenCorporatesUrl(other.openCorporatesUrl.get, other.holder.get)).apply(xhtml)
})
}

View File

@ -169,17 +169,17 @@ class OBPTransactionSnippet extends StatefulSnippet with PaginatorSnippet[OBPEnv
url getOrElse ""
}
val openCorporatesUrl = for{
a <- theAccount
oacc <- a.otherAccounts.get.find(o => o.holder.equals(otherUnmediatedHolder))
} yield oacc.openCorporatesUrl.get
val openCorporatesUrl = {
val urlBox = for{
a <- theAccount
openCorpUrl <- a.getUnmediatedOpenCorporatesUrl(consumer, otherUnmediatedHolder)
} yield openCorpUrl
urlBox.getOrElse("")
}
(
".amount *" #> transactionValue.mediated_amount(consumer).getOrElse(FORBIDDEN) &
".other_account_holder_name *" #> {
val omh = otherMediatedHolder._1.getOrElse(FORBIDDEN)
omh
}&
".other_account_holder_name *" #> otherMediatedHolder._1.getOrElse(FORBIDDEN) &
{
if(aliasImageSrc.equals("")){
".alias_image" #> NodeSeq.Empty & //remove the img tag
@ -204,8 +204,8 @@ class OBPTransactionSnippet extends StatefulSnippet with PaginatorSnippet[OBPEnv
else".other_acc_link [href]" #> otherAccWebsiteUrl
} &
{
if(openCorporatesUrl.getOrElse("").equals("")) ".open_corporates_link" #> NodeSeq.Empty
else ".open_corporates_link [src]" #> openCorporatesUrl
if(openCorporatesUrl.equals("")) ".open_corporates_link" #> NodeSeq.Empty
else ".open_corporates_link [href]" #> openCorporatesUrl
}
}
} &