Todo framework operational

This commit is contained in:
Rick Falkvinge
2013-09-08 10:09:35 +00:00
parent 7edf8d4248
commit b783fbdcd1
13 changed files with 591 additions and 7 deletions
+1 -1
View File
@@ -194,7 +194,7 @@ namespace Swarmops.Basic.Enums
/// </summary>
OrgCurrency,
/// <summary>
/// First bookkeeping year of org in Activizr (can set inbound balances for this year only)
/// First bookkeeping year of org in Swarmops (can set inbound balances for this year only)
/// </summary>
OrgFirstFiscalYear,
/// <summary>
+2
View File
@@ -9,5 +9,7 @@ namespace Swarmops.Logic.Financial
{
void Attest(Person attester);
void Deattest(Person deattester);
FinancialAccount Budget { get; }
}
}
+5
View File
@@ -148,6 +148,11 @@ namespace Swarmops.Logic.Financial
}
}
public FinancialAccount Budget // needed for IAttestable
{
get { return this.PayrollItem.Budget; }
}
public PayrollAdjustments Adjustments
{
+11
View File
@@ -241,9 +241,16 @@
<Compile Include="Support\TemporaryIdentity.cs" />
<Compile Include="Support\UrlTranslations.cs" />
<Compile Include="Swarm\Activists.cs" />
<Compile Include="Swarm\App_LocalResources\DashboardTodos.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>DashboardTodos.resx</DependentUpon>
</Compile>
<Compile Include="Swarm\AuditedPerson.cs" />
<Compile Include="Swarm\ChurnData.cs" />
<Compile Include="Swarm\ChurnDataPoint.cs" />
<Compile Include="Swarm\DashboardTodo.cs" />
<Compile Include="Swarm\DashboardTodos.cs" />
<Compile Include="Swarm\ExternalActivities.cs" />
<Compile Include="Swarm\ExternalActivity.cs" />
<Compile Include="Swarm\ExternalIdentity.cs" />
@@ -309,6 +316,10 @@
<LastGenOutput>Authentication.sv-SE.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Swarm\App_LocalResources\DashboardTodos.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>DashboardTodos.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>
+153
View File
@@ -0,0 +1,153 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1008
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Swarmops.Logic.Swarm.App_LocalResources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class DashboardTodos {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal DashboardTodos() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Swarmops.Logic.Swarm.App_LocalResources.DashboardTodos", typeof(DashboardTodos).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Attest cash advances {0}.
/// </summary>
internal static string Attest_CashAdvance_Many {
get {
return ResourceManager.GetString("Attest_CashAdvance_Many", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Attest cash advance #{0}.
/// </summary>
internal static string Attest_CashAdvance_One {
get {
return ResourceManager.GetString("Attest_CashAdvance_One", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Attest expense claims {0}.
/// </summary>
internal static string Attest_ExpenseClaim_Many {
get {
return ResourceManager.GetString("Attest_ExpenseClaim_Many", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Attest expense claim #{0}.
/// </summary>
internal static string Attest_ExpenseClaim_One {
get {
return ResourceManager.GetString("Attest_ExpenseClaim_One", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settle {0} payouts.
/// </summary>
internal static string Payout_Many {
get {
return ResourceManager.GetString("Payout_Many", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settle one payout.
/// </summary>
internal static string Payout_One {
get {
return ResourceManager.GetString("Payout_One", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settle {0} overdue payouts.
/// </summary>
internal static string Payout_Overdue_Many {
get {
return ResourceManager.GetString("Payout_Overdue_Many", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settle one overdue payout.
/// </summary>
internal static string Payout_Overdue_One {
get {
return ResourceManager.GetString("Payout_Overdue_One", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settle {0} urgent payouts.
/// </summary>
internal static string Payout_Urgent_Many {
get {
return ResourceManager.GetString("Payout_Urgent_Many", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settle one urgent payout.
/// </summary>
internal static string Payout_Urgent_One {
get {
return ResourceManager.GetString("Payout_Urgent_One", resourceCulture);
}
}
}
}
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Attest_CashAdvance_Many" xml:space="preserve">
<value>Attest cash advances {0}</value>
</data>
<data name="Attest_CashAdvance_One" xml:space="preserve">
<value>Attest cash advance #{0}</value>
</data>
<data name="Attest_ExpenseClaim_Many" xml:space="preserve">
<value>Attest expense claims {0}</value>
</data>
<data name="Attest_ExpenseClaim_One" xml:space="preserve">
<value>Attest expense claim #{0}</value>
</data>
<data name="Payout_Many" xml:space="preserve">
<value>Settle {0} payouts</value>
<comment>Instead of "Pay out payout". That sounds too repetitititive.</comment>
</data>
<data name="Payout_One" xml:space="preserve">
<value>Settle one payout</value>
</data>
<data name="Payout_Overdue_Many" xml:space="preserve">
<value>Settle {0} overdue payouts</value>
</data>
<data name="Payout_Overdue_One" xml:space="preserve">
<value>Settle one overdue payout</value>
</data>
<data name="Payout_Urgent_Many" xml:space="preserve">
<value>Settle {0} urgent payouts</value>
</data>
<data name="Payout_Urgent_One" xml:space="preserve">
<value>Settle one urgent payout</value>
</data>
</root>
+24
View File
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Swarmops.Logic.Swarm
{
public class DashboardTodo
{
public string Icon { get; set; }
public string Description { get; set; }
public string Url { get; set; }
public TodoUrgency Urgency { get; set; }
}
public enum TodoUrgency
{
Unknown = 0,
Normal,
Yellow,
Orange,
Red
}
}
+222
View File
@@ -0,0 +1,222 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using Swarmops.Basic.Enums;
using Swarmops.Logic.DashboardTasks;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
namespace Swarmops.Logic.Swarm
{
public class DashboardTodos: List<DashboardTodo>
{
public static DashboardTodos ForPerson (Person person, Organization organization)
{
DashboardTodos result = new DashboardTodos();
result.AddExpenseClaimAttestations(person, organization);
result.AddCashAdvanceAttestations(person, organization);
result.AddPayouts(person, organization);
// TODO: Add any hooks
return result;
}
// TODO: Refactor the attest-X functions into one function with minimal differences
private void AddExpenseClaimAttestations(Person person, Organization organization)
{
ExpenseClaims claims = ExpenseClaims.ForOrganization(organization);
List<int> expenseClaimIds = new List<int>();
bool isPersonOrgAdmin = false;
if (person.Identity == 1)
{
isPersonOrgAdmin = true; // TODO: Make more advanced, obviously
}
foreach (ExpenseClaim claim in claims)
{
if (claim.Attested)
{
continue;
}
bool attestable = false;
if (claim.Budget.OwnerPersonId == 0 && isPersonOrgAdmin)
{
attestable = true;
}
else if (claim.Budget.OwnerPersonId == person.Identity)
{
attestable = true;
}
if (attestable)
{
expenseClaimIds.Add(claim.Identity);
}
}
if (expenseClaimIds.Count > 0)
{
DashboardTodo todo = new DashboardTodo();
if (expenseClaimIds.Count > 1)
{
todo.Description = String.Format(App_LocalResources.DashboardTodos.Attest_ExpenseClaim_Many, Formatting.GenerateRangeString(expenseClaimIds));
}
else
{
todo.Description = String.Format(App_LocalResources.DashboardTodos.Attest_ExpenseClaim_One, expenseClaimIds[0]);
}
todo.Icon = "/Images/PageIcons/iconshock-stamped-paper-16px.png";
todo.Url = "/Pages/v5/Financial/AttestCosts.aspx";
this.Add(todo);
}
}
private void AddCashAdvanceAttestations(Person person, Organization organization)
{
CashAdvances advances = CashAdvances.ForOrganization(organization);
List<int> cashAdvanceIds = new List<int>();
bool isPersonOrgAdmin = false;
if (person.Identity == 1)
{
isPersonOrgAdmin = true; // TODO: Make more advanced, obviously
}
foreach (CashAdvance advance in advances)
{
if (advance.Attested)
{
continue;
}
bool attestable = false;
if (advance.Budget.OwnerPersonId == 0 && isPersonOrgAdmin)
{
attestable = true;
}
else if (advance.Budget.OwnerPersonId == person.Identity)
{
attestable = true;
}
if (attestable)
{
cashAdvanceIds.Add(advance.Identity);
}
}
if (cashAdvanceIds.Count > 0)
{
DashboardTodo todo = new DashboardTodo();
if (cashAdvanceIds.Count > 1)
{
todo.Description = String.Format(App_LocalResources.DashboardTodos.Attest_CashAdvance_Many, Formatting.GenerateRangeString(cashAdvanceIds));
}
else
{
todo.Description = String.Format(App_LocalResources.DashboardTodos.Attest_CashAdvance_One, cashAdvanceIds[0]);
}
todo.Icon = "/Images/PageIcons/iconshock-stamped-paper-16px.png";
todo.Url = "/Pages/v5/Financial/AttestCosts.aspx";
this.Add(todo);
}
}
private void AddPayouts(Person person, Organization organization)
{
if (!person.HasAccess(new Access(organization, AccessAspect.Financials, AccessType.Write)))
{
return; // do not add this if can't pay out
}
DashboardTodo todoNormal = new DashboardTodo();
DashboardTodo todoUrgent = new DashboardTodo();
DashboardTodo todoOverdue = new DashboardTodo();
todoNormal.Url =
todoUrgent.Url =
todoOverdue.Url = "/Pages/v5/Financial/PayOutMoney.aspx";
todoNormal.Icon =
todoUrgent.Icon =
todoOverdue.Icon = "/Images/PageIcons/iconshock-money-envelope-16px.png";
int payoutCount = 0;
int urgentPayoutCount = 0;
int overduePayoutCount = 0;
Payouts payouts = Payouts.Construct(organization);
foreach (Payout payout in payouts)
{
payoutCount++;
if (payout.DependentInvoices.Count > 0)
{
if (payout.ExpectedTransactionDate < DateTime.Today)
{
overduePayoutCount++;
}
else if (payout.ExpectedTransactionDate < DateTime.Today.AddDays(7))
{
urgentPayoutCount++;
}
}
}
if (payoutCount > 0)
{
todoNormal.Description = payoutCount > 1
? String.Format(App_LocalResources.DashboardTodos.Payout_Many,
payoutCount)
: App_LocalResources.DashboardTodos.Payout_One;
this.Add(todoNormal);
}
if (overduePayoutCount > 0)
{
todoOverdue.Description = overduePayoutCount > 1
? String.Format(App_LocalResources.DashboardTodos.Payout_Overdue_Many,
payoutCount)
: App_LocalResources.DashboardTodos.Payout_Overdue_One;
todoOverdue.Urgency = TodoUrgency.Red;
this.Add(todoOverdue);
}
if (urgentPayoutCount > 0)
{
todoUrgent.Description = overduePayoutCount > 1
? String.Format(App_LocalResources.DashboardTodos.Payout_Urgent_Many,
payoutCount)
: App_LocalResources.DashboardTodos.Payout_Urgent_One;
todoUrgent.Urgency = TodoUrgency.Yellow;
this.Add(todoUrgent);
}
}
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ using Swarmops.Logic.Structure;
/// <summary>
/// Summary description for PageV5Base
/// Base class to use for all pages that uses the Activizr-v5 master page
/// Base class to use for all pages that uses the Swarmops-v5 master page
/// </summary>
public class DataV5Base : System.Web.UI.Page
+8 -2
View File
@@ -17,7 +17,7 @@
<link href='https://fonts.googleapis.com/css?family=Arimo:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css' />
<!-- page title -->
<title>Activizr - Pirate Edition</title>
<title>Swarmops</title>
<!-- telerik style sheet manager, followed by style sheet, followed by script style sheets -->
<telerik:RadStyleSheetManager id="RadStyleSheetManager" runat="server" />
@@ -293,7 +293,13 @@
<div class="box">
<div class="content">
<asp:Label ID="LabelActionItemsHere" runat="server" />
<asp:Repeater runat="server" ID="RepeaterTodoItems"><ItemTemplate>
<div class="link-row-encaps" onclick="document.location='<%# DataBinder.Eval(Container.DataItem, "Url") %>';" >
<div class="link-row-icon" style="background-image:url('<%# DataBinder.Eval(Container.DataItem, "Icon") %>')"></div>
<asp:Label ID="Label1" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>' runat="server" />
</div>
</ItemTemplate></asp:Repeater>
<asp:Label ID="LabelNoTodoItems" runat="server" Visible="False" />
</div>
</div>
</div>
+11 -1
View File
@@ -80,7 +80,17 @@ namespace Swarmops
this.LabelActionPlaceholder1.Text = "Action shortcut 1 (TODO)";
this.LabelActionPlaceholder2.Text = "Action shortcut 2 (TODO)";
this.LabelActionItemsHere.Text = "Action items here (TODO)";
this.LabelNoTodoItems.Text = "No Action Items (LOC)";
// Set up todo items
DashboardTodos todos = DashboardTodos.ForPerson(_currentUser, _currentOrganization);
this.RepeaterTodoItems.DataSource = todos;
this.RepeaterTodoItems.DataBind();
this.LabelNoTodoItems.Visible = (todos.Count == 0);
// Set up main menu
RadMenu mainMenu = FindControl("MainMenu") as RadMenu;
+1 -1
View File
@@ -11,7 +11,7 @@
<link href='https://fonts.googleapis.com/css?family=Arimo:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css' />
<telerik:RadStyleSheetManager id="RadStyleSheetManager" runat="server" />
<link href="../Style/style-v5.css" rel="stylesheet" type="text/css" />
<title>Activizr Beta - Login</title>
<title>Swarmops Alpha - Login</title>
</head>
<body class="loginpage">
+1 -1
View File
@@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle ("Activizr Utility Classes")]
[assembly: AssemblyTitle ("Swarmops Utility Classes")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Disorganized")]