From 40c730cffa8858766d26cbae27a2939195200db7 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 9 Feb 2013 18:44:23 +0000 Subject: [PATCH] Committing before rename of PirateDb to SwarmDb --- .../Icons/iconshock-balloon-undo-16px.png | Bin 738 -> 950 bytes Site5/Images/Icons/undo-16px.png | Bin 0 -> 836 bytes Site5/Pages/v5/Financial/AttestCosts.aspx | 64 ++++++++++--- Site5/Pages/v5/Financial/AttestCosts.aspx.cs | 87 ++++++++++++++++++ 4 files changed, 137 insertions(+), 14 deletions(-) create mode 100644 Site5/Images/Icons/undo-16px.png diff --git a/Site5/Images/Icons/iconshock-balloon-undo-16px.png b/Site5/Images/Icons/iconshock-balloon-undo-16px.png index 637dd1fb159d223c48dcb67342f18bc831308275..2754b4becbb766ef1cf3117700f4ec479f7f903c 100644 GIT binary patch delta 879 zcmV-#1CadU1-1u}RDTU2B;EMi+5i9pLrFwIR5;6pl1pe@WdMc0|Gs82lgT7AHO8iS z8H3WASWWOzD?w^0R@%C-MN&}cLfp7N-dpAeRq1|i_wqAKgj<}&_8g$^~QT|KVR4Mx01Is7oJNwO@T=_>os`3SJz2IdSy((^G#|YTbML@4_-orRzcn zApk{CS12JUx__?ny_&d^%HS0@&lv!NLwh5SKY92krCHs>_w^|h!uA4jc5-OG<67iUdnugF2yf!|?ZJru*n=4|kxJ1Vk74LmXdgm13l)cSdXqwVi*vtbF_6SsI#|j`ViBG0&Nlv7 zy2kQ)hD0)kX_*LJN3$Jwmn(h7zdXzI!Xl+ohP9=6bi-tBevz$%vH9%GMY7o({XJ0}=@ZnY zsyHsQi))TPuxD74M)-K=tw};*ON2reCC}yVzE)PUIZWL`c@8^!o9O6C;QA8NFqyr& zA=YLuj_Gk(O{v88XU#}7ep_=~m8w-yv>mdAB7YUf!>Lt?HVM4CL)=0>-5JIS|?TD)@t6SNn zh0*gLzVng|>gE$ijvnjC?ig68qeohz4JzJX2~9x0SjMTzKm~rF@*7hZzCCraRJIF1 z8fds;{4H>sS|8g|S{Na)?Xt-JKKE6zR9aSn^!#$6kXv26RxFhYfC)r^9w09Ojy-eY zo@zKTEscgv%`4|KmwtJF`oj51pz#Kv-6((p0w4#>{{_uSi;XO*ajF0S002ovPDHLk FV1lB=w)p@6 delta 666 zcmV;L0%iTS2jT^gRDTRM6JZ39bN~PXZ%IT!R5;7UQ{PKdaU4DO?#}6)-Kop`H6`#@ zE`rbmDItO$N_walN$5T3!HE8Vo`UEpq^HPAva}Kn%%V}@oY^wxkIikmDWhDQb3gCh z_3rNO?%UHM=?C->eV#t>;hY2Ka}Myohx*;&!Q+vRrh}$#N`Iwlq-hF@EU(VIwG3VD zyX5;L!K1O~$8>x54Of&KYKqhh)HDrQ$$^(7q;^CU(8~CU_O`RXR2?_JxianakQkrJ zNs2-~xWnX?ZG!}3JmIAbiAoYNFF1+WHaC&SsPfCe$kS7et){`|`dUJPq8`3nL;w9r zOxs+Tm|8`fsecNE8V03hERv$sBqW3Zmt&Em^8^*fy1`;yF_EMUwGrYlI{6+Kdk*8y z_46oaHMl)wfgp;A#FJpu1!(U&dISI%0O&q*&ZuSe2CIDqHF_4-`7m-h1#A8k3X8s= zwYeS(4mSc@F%T6EAtS@Rae)quTSlT|&dHh<(p%$W2GnACgqH(_-LRx~yw~3PCG`c!W zh^GYN3v5%~#rd9Po7KI`L}Np1ETh(*ZmF##30|P$Tne8<5!6+)sI4*}7>yHeAWZq4 zi(1Bq+36VoEP%ovgt7oa0DJ(*-*$%jCvE%&dlN_@v*Q2h5C8xG07*qoM6N<$g8lwM A)&Kwi diff --git a/Site5/Images/Icons/undo-16px.png b/Site5/Images/Icons/undo-16px.png new file mode 100644 index 0000000000000000000000000000000000000000..825b083cd1e8e3c659b1e5c76d213b4e2f8dfe1f GIT binary patch literal 836 zcmV-K1H1f*P)_2@Xyo=CS|)0?|oC zK~y-)g;H5alwlM-=ldrIrz|SMj38?&n5d~Rv8b0wDj!NBu!pc{!Iy}rd-9d*=k7RULQ+ry|x6y3+WoO|xMhxkW`2mvSn988fk z|Ln851hadb!4S(kI-0g^px z*l=Q1Q)p|^_0QQo9ZfI|T_6Bp#UPdefMS^v?u%-B&ph6&8|HEmQNvG2yYs3#tGDx~ z06;7ngd$@12l^I%t!Z&v zrb&n}XPN8Vnw5)doKsS6r%p~TDK6ahMpI}52r3O1OFS6>QkAc}f8LvlUnhM%`ifvE z7(WLBr*rB|Po*#SS$Xpg00w~41@q>3sp6Wn`h#Nwy}@y|gfyn0_>nusMLLdOW>6M(QH83AzPbU{v$-X9@Ju}q!muJI?FQzut{^!l@I zmNu52yZa@-^H;ql08BlKd*}Du22elv#^xERDUEA0-9?rWW1yp<>{!8;8USStEgiEj z-g-Ir+t*51rXjE_I?#J_q$9BjfKLrjwg9}`o|{=`8nN;xm-ame@BlzmQ&fXq(xV}2 z{q3h7UfN#<;1Nl4$Oj~&BJ%k4mHZ9>Z6q5-B*~_!K)9>bo4|;taCgrAj5K!&fQKZz z|7K+czyY9-q$whH06CUrO;SpQ0lWiHO)@;R82TnMn`VOD~ O0000 -

+

- - - - - - - + + + + + + +
ItemBeneficiaryDescriptionBudgetRequestedDocsAction
diff --git a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs index 3e1405eb..f0eddf7b 100644 --- a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs +++ b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs @@ -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; + } } } \ No newline at end of file