Committing before rename of PirateDb to SwarmDb

This commit is contained in:
Rick Falkvinge
2013-02-09 18:44:23 +00:00
parent 618030c2ea
commit 40c730cffa
4 changed files with 137 additions and 14 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 738 B

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

+50 -14
View File
@@ -25,30 +25,44 @@
$('#TableAttestableCosts').datagrid(
{
onLoadSuccess: function () {
$(".LocalIconApproval").attr("src", "/Images/Icons/iconshock-greentick-16px-desat-light.png");
$(".LocalIconApproval").attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png");
$(".LocalIconApproved").attr("src", "/Images/Icons/iconshock-greentick-16px.png");
$(".LocalIconApproved, .LocalIconDenied").css("display", "none");
$(".LocalIconDenial").attr("src", "/Images/Icons/iconshock-redcross-16px-desat-light.png");
$(".LocalIconDenial").attr("src", "/Images/Icons/iconshock-balloon-no-16px.png");
$(".LocalIconApproval, .LocalIconApproved, .LocalIconDenial").css("cursor", "pointer");
$(".LocalIconApproval").mouseover(function () {
if ($(this).attr("rel") != "loading") {
$(this).attr("src", "/Images/Icons/iconshock-greentick-16px-desat.png");
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-16px-hot.png");
}
});
$(".LocalIconApproval").mouseout(function () {
if ($(this).attr("rel") != "loading") {
$(this).attr("src", "/Images/Icons/iconshock-greentick-16px-desat-light.png");
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png");
}
});
$(".LocalIconApproved").mouseover(function () {
if ($(this).attr("rel") != "loading") {
$(this).attr("src", "/Images/Icons/undo-16px.png");
}
});
$(".LocalIconApproved").mouseout(function () {
if ($(this).attr("rel") != "loading") {
$(this).attr("src", "/Images/Icons/iconshock-greentick-16px.png");
}
});
$(".LocalIconApproval").click(function () {
if ($(this).attr("rel") != "loading") {
$(this).attr("rel", "loading");
$(this).attr("src", "/Images/Abstract/ajaxloader-medium.gif");
$("#IconDenial" + $(this).attr("baseid")).fadeTo(1000, 0.01).css("cursor","default");
$("#IconDenial" + $(this).attr("baseid")).fadeTo(1000, 0.01).css("cursor", "default");
$(this).fadeOut(2000, function () {
$(this).css("display", "none");
$(this).attr("src", "/Images/Icons/iconshock-greentick-16px-desat-light.png");
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png");
$(this).attr("rel", "active");
$("#IconApproved" + $(this).attr("baseid")).fadeIn(100);
alertify.success("Foo approved.");
@@ -56,6 +70,7 @@
}
});
$(".LocalIconApproved").click(function () {
if ($(this).attr("rel") != "loading") {
$(this).attr("rel", "loading");
@@ -73,6 +88,27 @@
}
});
$(".LocalIconDenial").mouseover(function () {
if ($(this).attr("rel") != "loading") {
$(this).attr("src", "/Images/Icons/iconshock-balloon-no-16px-hot.png");
}
});
$(".LocalIconDenial").mouseout(function () {
if ($(this).attr("rel") != "loading") {
$(this).attr("src", "/Images/Icons/iconshock-balloon-no-16px.png");
}
});
$(".LocalIconDenial").click(function () {
alert('Denying attestation is not yet implemented, but you can just leave the unwanted cost here until it is.');
});
}
}
);
@@ -87,19 +123,19 @@
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<h2><asp:Label runat="server" ID="LabelAttestCostsHeader" Text="Attest Costs XYZ" /></h2>
<h2><asp:Label runat="server" ID="LabelAttestCostsHeader" Text="XYZ Costs Awaiting Your Attestation" /></h2>
<table id="TableAttestableCosts" class="easyui-datagrid" style="width:680px;height:400px"
data-options="rownumbers:false,singleSelect:false,fit:false,loading:false,selectOnCheck:true,checkOnSelect:true,url:'Json-AttestableCosts.aspx'"
idField="itemId">
<thead>
<tr>
<th data-options="field:'item',width:60">Item</th>
<th data-options="field:'beneficiary',width:120,sortable:true">Beneficiary</th>
<th data-options="field:'description',width:160">Description</th>
<th data-options="field:'budgetName',width:160,sortable:true">Budget</th>
<th data-options="field:'amountRequested',width:80,align:'right',sortable:true,order:'asc'">Requested</th>
<th data-options="field:'dox',width:40,align:'center'">Docs</th>
<th data-options="field:'actions',width:53,align:'center'">Action</th>
<th data-options="field:'item',width:60"><asp:Label ID="LabelGridHeaderItem" runat="server" Text="XYZ Item"/></th>
<th data-options="field:'beneficiary',width:120,sortable:true"><asp:Label ID="LabelGridHeaderBeneficiary" runat="server" Text="XYZ Beneficiary" /></th>
<th data-options="field:'description',width:160"><asp:Label ID="LabelGridHeaderDescription" runat="server" Text="XYZ Description" /></th>
<th data-options="field:'budgetName',width:160,sortable:true"><asp:Label ID="LabelGridHeaderBudget" runat="server" Text="XYZ Budget" /></th>
<th data-options="field:'amountRequested',width:80,align:'right',sortable:true,order:'asc'"><asp:Label ID="LabelGridHeaderRequested" runat="server" Text="XYZ Requested" /></th>
<th data-options="field:'dox',width:40,align:'center'"><asp:Label ID="LabelGridHeaderDocs" runat="server" Text="Doxyz" /></th>
<th data-options="field:'actions',width:53,align:'center'"><asp:Label ID="LabelGridHeaderAction" runat="server" Text="Axyztion" /></th>
</tr>
</thead>
</table>
@@ -2,9 +2,14 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.ServiceModel.Security;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Swarm;
namespace Swarmops.Frontend.Pages.v5.Financial
{
@@ -32,5 +37,87 @@ namespace Swarmops.Frontend.Pages.v5.Financial
this.PageTitle = Resources.Pages.Finance.AttestCosts_PageTitle;
this.InfoBoxLiteral = Resources.Pages.Finance.AttestCosts_Info;
}
[WebMethod]
public static string Attest (string identifier)
{
string identity = HttpContext.Current.User.Identity.Name;
string[] identityTokens = identity.Split(',');
string userIdentityString = identityTokens[0];
string organizationIdentityString = identityTokens[1];
int currentUserId = Convert.ToInt32(userIdentityString);
int currentOrganizationId = Convert.ToInt32(organizationIdentityString);
Person currentUser = Person.FromIdentity(currentUserId);
Organization currentOrganization = Organization.FromIdentity(currentOrganizationId);
char costType = identifier[0];
int itemId = Int32.Parse(identifier.Substring(1));
string beneficiary = string.Empty;
string result = string.Empty;
switch(costType)
{
case 'A': // Case advance
CashAdvance advance = CashAdvance.FromIdentity(itemId);
if (advance.OrganizationId != currentOrganizationId)
{
throw new InvalidOperationException("Called to attest out-of-org line item");
}
if (advance.FinancialAccount.OwnerPersonId != currentUserId)
{
throw new SecurityAccessDeniedException("Called without attestation privileges");
}
result = "XYZ Cash Advance";
advance.Attest(currentUser);
break;
}
return result;
}
[WebMethod]
public static string Deattest(string identifier)
{
string identity = HttpContext.Current.User.Identity.Name;
string[] identityTokens = identity.Split(',');
string userIdentityString = identityTokens[0];
string organizationIdentityString = identityTokens[1];
int currentUserId = Convert.ToInt32(userIdentityString);
int currentOrganizationId = Convert.ToInt32(organizationIdentityString);
Person currentUser = Person.FromIdentity(currentUserId);
Organization currentOrganization = Organization.FromIdentity(currentOrganizationId);
char costType = identifier[0];
int itemId = Int32.Parse(identifier.Substring(1));
string beneficiary = string.Empty;
string result = string.Empty;
switch (costType)
{
case 'A': // Case advance
CashAdvance advance = CashAdvance.FromIdentity(itemId);
if (advance.OrganizationId != currentOrganizationId)
{
throw new InvalidOperationException("Called to attest out-of-org line item");
}
if (advance.FinancialAccount.OwnerPersonId != currentUserId)
{
throw new SecurityAccessDeniedException("Called without attestation privileges");
}
result = "XYZ Cash Advance";
advance.Deattest(currentUser);
break;
}
return result;
}
}
}