Skip to content

Commit 9a9bdf8

Browse files
public download fixed #57
1 parent ba7c2a7 commit 9a9bdf8

2 files changed

Lines changed: 59 additions & 45 deletions

File tree

Controllers/LUICalculationController.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public ActionResult ShowPrimaryData(long datasetID, bool isPublicAccess)
8585
LUIQueryModel lUIQueryModel = new LUIQueryModel();
8686
lUIQueryModel.RawVsCalc.SelectedValue = "unstandardized";
8787
lUIQueryModel.DownloadDatasetId = datasetID.ToString();
88+
lUIQueryModel.IsPublicAccess = isPublicAccess;
8889
Session["LUICalModel"] = lUIQueryModel;
8990

9091
DataModel model = new DataModel();
@@ -306,11 +307,21 @@ public ActionResult DownloadFile(string mimeType)
306307
//send mail
307308
var es = new EmailService();
308309
string user;
309-
using (UserManager userManager = new UserManager())
310+
311+
LUIQueryModel model = (LUIQueryModel)Session["LUICalModel"];
312+
313+
if (model.IsPublicAccess)
310314
{
311-
user = userManager.FindByNameAsync(HttpContext.User.Identity.Name).Result.DisplayName;
315+
user = "public downloaded";
312316
}
313-
LUIQueryModel model = (LUIQueryModel)Session["LUICalModel"];
317+
else
318+
{
319+
using (UserManager userManager = new UserManager())
320+
{
321+
user = "downloaded by " + userManager.FindByNameAsync(HttpContext.User.Identity.Name).Result.DisplayName;
322+
}
323+
}
324+
314325
string datasetId;
315326
if (model.ComponentsSet.SelectedValue.Contains("old"))
316327
datasetId = Models.Settings.get("lui:datasetOldComponentsSet").ToString();
@@ -319,7 +330,7 @@ public ActionResult DownloadFile(string mimeType)
319330

320331
string version = DataAccess.GetDatasetInfo(datasetId, GetServerInformation()).Version;
321332

322-
string text = "LUI Calculation file <b>\"" + Path.GetFileName(pathData) + "\"</b> with id <b>(" + datasetId + ")</b> version <b>(" + version + ")</b> was downloaded by <b>" + user + "</b>";
333+
string text = "LUI Calculation file <b>\"" + Path.GetFileName(pathData) + "\"</b> with id <b>(" + datasetId + ")</b> version <b>(" + version + ")</b> was <b>" + user + "</b>";
323334
es.Send("LUI data was downloaded (Id: " + datasetId + ", Version: " + version + ")", text, "bexis-sys@listserv.uni-jena.de");
324335

325336

Views/LUICalculation/Index.cshtml

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,61 +10,63 @@
1010
"CalculateLUI",
1111
"CalculateLUI",
1212
new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divResultGrid", OnBegin = "$('#divResultButtons').hide(); $('#divResultGrid').empty(); $('#dtmLuiSpinner').show(); $('html, body').animate({ scrollTop: 0 }, 'slow');", OnSuccess = "$('#divResultButtons').show(); $('#dtmLuiSpinner').hide();resetAllTelerikIconTitles();" },
13-
new { @autocomplete= "off" })
13+
new { @autocomplete = "off" })
1414
)
1515
{
16-
<td style="width: 600px; vertical-align:top;">
16+
@Html.HiddenFor(m => m.IsPublicAccess)
1717

18-
@Html.ActionLink("How to reference", "DownloadPDF", new { fileName = "LUI-citation.pdf" }, new { @class = "bx-button small function", target = "_blank" })
19-
@Html.ActionLink("How to use the tool", "DownloadPDF", new { fileName = "HowToPlusDiagram.pdf" }, new { @class = "bx-button small function", target = "_blank" })
20-
@Html.ActionLink("LUI changes docu", "DownloadPDF", new { fileName = "LuiChangesInfo.pdf" }, new { @class = "bx-button small function", target = "_blank" })
21-
@if (Model.MissingComponentData.Count() != 0 && Model.IsPublicAccess == false)
22-
{
23-
<div class="dtm-divBox">
24-
<p class="dtm-para_green">Warning: Some input data needed for calculation is not completely available. Below you will find the affected years, and for which plots the data is missing. For this year, use the LUI just for testing purposes. For publications, use only LUI where no warning is given.</p>
18+
<td style="width: 600px; vertical-align:top;">
2519

26-
<div class="dtm-controls">
20+
@Html.ActionLink("How to reference", "DownloadPDF", new { fileName = "LUI-citation.pdf" }, new { @class = "bx-button small function", target = "_blank" })
21+
@Html.ActionLink("How to use the tool", "DownloadPDF", new { fileName = "HowToPlusDiagram.pdf" }, new { @class = "bx-button small function", target = "_blank" })
22+
@Html.ActionLink("LUI changes docu", "DownloadPDF", new { fileName = "LuiChangesInfo.pdf" }, new { @class = "bx-button small function", target = "_blank" })
23+
@if (Model.MissingComponentData.Count() != 0 && Model.IsPublicAccess == false)
24+
{
25+
<div class="dtm-divBox">
26+
<p class="dtm-para_green">Warning: Some input data needed for calculation is not completely available. Below you will find the affected years, and for which plots the data is missing. For this year, use the LUI just for testing purposes. For publications, use only LUI where no warning is given.</p>
27+
28+
<div class="dtm-controls">
2729

2830
@if (Model.MissingComponentData.Count() == 0)
2931
{
3032
<div>No warnings.</div>
3133
}
3234
else
3335
{
34-
<div class="box">
35-
<b>Source Dataset:</b> @Model.NewComponentsSetDatasetId<br />
36-
</div>
37-
<div class="box">
38-
<b>Version:</b> @Model.NewComponentsSetDatasetVersion
39-
</div>
40-
<div class="box">
41-
<b>Last update:</b> @Model.NewComponentsSetLastUpdate
42-
</div>
43-
<br /><br />
44-
foreach (var missingCompData in Model.MissingComponentData)
45-
{
46-
4736
<div class="box">
48-
<b>Year:</b> @missingCompData.Year<br />
37+
<b>Source Dataset:</b> @Model.NewComponentsSetDatasetId<br />
4938
</div>
5039
<div class="box">
51-
<b>Missing plots:</b><br /><a class="plotClick">Click to show</a>
40+
<b>Version:</b> @Model.NewComponentsSetDatasetVersion
5241
</div>
53-
<div class="plots">
54-
@foreach (var plot in missingCompData.PlotIds)
55-
{
56-
@plot<br />
57-
}
42+
<div class="box">
43+
<b>Last update:</b> @Model.NewComponentsSetLastUpdate
5844
</div>
59-
45+
<br /><br />
46+
foreach (var missingCompData in Model.MissingComponentData)
47+
{
48+
49+
<div class="box">
50+
<b>Year:</b> @missingCompData.Year<br />
51+
</div>
52+
<div class="box">
53+
<b>Missing plots:</b><br /><a class="plotClick">Click to show</a>
54+
</div>
55+
<div class="plots">
56+
@foreach (var plot in missingCompData.PlotIds)
57+
{
58+
@plot<br />
59+
}
60+
</div>
61+
62+
}
6063
}
61-
}
62-
64+
65+
</div>
66+
67+
<br />
6368
</div>
64-
65-
<br />
66-
</div>
67-
}
69+
}
6870
<div id="divQuery00" class="dtm-divBox">
6971
<p class="dtm-para_green">Which input data do you want to use for the calculation (default = new set).</p>
7072
<div class="dtm-controls">
@@ -161,8 +163,8 @@
161163
</label>
162164
</span>
163165
}
164-
</div>
165-
<div id="yearsNew" v>
166+
</div>
167+
<div id="yearsNew" v>
166168
@for (int i = 0; i < Model.AvailableYearsNewComp.Count(); i++)
167169
{
168170
<span style="flex-grow: 0">
@@ -173,7 +175,7 @@
173175
</label>
174176
</span>
175177
}
176-
</div>
178+
</div>
177179
</div>
178180

179181
<div class="dtm-message dtm-para_green" id="dtmLocationMessages"><div data-location="ALB">@Settings.get("lui:msg:alb")</div><div data-location="HAI">@Settings.get("lui:msg:hai")</div><div data-location="SCH">@Settings.get("lui:msg:sch")</div></div>
@@ -218,7 +220,8 @@
218220
<td style="vertical-align:top;">
219221
<div id="divResultButtons" style="display:none"
220222
data-prepurl="@Url.Action("PrepareDownloadFile", "LUICalculation")"
221-
data-downloadurl="@Url.Action("DownloadFile", "LUICalculation")">
223+
data-downloadurl="@Url.Action("DownloadFile", "LUICalculation")"
224+
data-isPublic="@Model.IsPublicAccess">
222225
<button type="button" class="dtm-download bx-button function" data-download="text/csv">Download (zip)</button>
223226
@*<button type="button" class="dtm-download bx-button function" data-download="text/tsv">Download Tab Separated</button>*@
224227
</div>

0 commit comments

Comments
 (0)