Permalink
Browse files

Fix initial setup workflow issues. Add support for creating and editing.

* Application.cs:
* BuildService.cs:
* ProjectController.cs: Fix typo.

* UserController.cs:
* HomeController.cs:
* LogOnUserControl.ascx: Fix initial setup workflow issues.

* Cydin.csproj:
* ServiceModel.cs:
* Index.aspx:
* SiteAdminController.cs:
* EditApplication.aspx: Add support for creating and editing
  applications.

* Settings.aspx: Improve help message.
  • Loading branch information...
1 parent 2ee5302 commit 5619edb80a14d7a1b748370060e3b3f423edee08 @slluis committed Oct 20, 2010
@@ -195,7 +195,7 @@ static void UpdateRepos (int appId, bool updateAll)
try {
reposToBuild.Add (Path.GetFullPath (Path.GetDirectoryName (f)));
File.Delete (f);
- string f2 = Path.ChangeExtension (f, m.CurrentApplication.AddingPackageExtension);
+ string f2 = Path.ChangeExtension (f, m.CurrentApplication.AddinPackageExtension);
if (File.Exists (f2))
File.Delete (f2);
}
@@ -246,7 +246,7 @@ static void FindFiles (HashSet<string> fileList, string path)
internal static void GenerateInstallerFile (UserModel m, string packagesPath, Release rel, params string[] platforms)
{
- string file = Path.ChangeExtension (packagesPath, m.CurrentApplication.AddingPackageExtension);
+ string file = Path.ChangeExtension (packagesPath, m.CurrentApplication.AddinPackageExtension);
using (StreamWriter sw = new StreamWriter (file)) {
GenerateInstallerXml (sw, m, rel, platforms);
}
@@ -26,8 +26,10 @@ public ActionResult Index ()
if (Settings.Default.SupportsMultiApps) {
string app = UserModel.GetCurrentAppName ();
if (string.IsNullOrEmpty (app) || app == "home")
- return Redirect (ControllerHelper.GetActionUrl ("home", "SiteHome", "Index"));
+ return Redirect (ControllerHelper.GetActionUrl ("home", "Index", "SiteHome"));
}
+ else if (UserModel.GetCurrent ().CurrentApplication == null)
+ return RedirectToAction ("Index", "SiteAdmin");
return View ();
}
@@ -161,7 +161,7 @@ public ActionResult ReleasePackageInstaller (int id)
Release rel = m.GetRelease (id);
StringWriter sw = new StringWriter ();
BuildService.GenerateInstallerXml (sw, m, rel, rel.PlatformsList);
- return File (Encoding.UTF8.GetBytes (sw.ToString()), "application/x-" + m.CurrentApplication.AddingPackageSubextension + "-mpack", rel.AddinId + "-" + rel.Version + m.CurrentApplication.AddingPackageExtension);
+ return File (Encoding.UTF8.GetBytes (sw.ToString()), "application/x-" + m.CurrentApplication.AddinPackageSubextension + "-mpack", rel.AddinId + "-" + rel.Version + m.CurrentApplication.AddinPackageExtension);
}
public ActionResult ConfirmDelete (int id)
@@ -101,18 +101,62 @@ public ActionResult SaveSettings (Settings s)
if (!Settings.Default.InitialConfiguration)
m.CheckIsSiteAdmin ();
- m.UpdateSettings (s);
+ Settings.Default.DataPath = s.DataPath;
+ Settings.Default.OperationMode = s.OperationMode;
+ Settings.Default.WebSiteHost = s.WebSiteHost;
+ Settings.Default.SmtpHost = s.SmtpHost;
+ Settings.Default.SmtpPassword = s.SmtpPassword;
+ Settings.Default.SmtpPort = s.SmtpPort;
+ Settings.Default.SmtpUser = s.SmtpUser;
+ Settings.Default.SmtpUseSSL = s.SmtpUseSSL;
+
+ m.UpdateSettings (Settings.Default);
- Settings.Default = s;
Cydin.MvcApplication.UpdateRoutes ();
if (!ServiceModel.GetCurrent ().ThereIsAdministrator ())
- return Redirect (ControllerHelper.GetActionUrl ("home", "User", "Login"));
+ return Redirect (ControllerHelper.GetActionUrl ("home", "Login", "User"));
else {
ServiceModel.GetCurrent ().EndInitialConfiguration ();
return Redirect (ControllerHelper.GetActionUrl ("home", null, null));
}
}
+ public ActionResult NewApplication ()
+ {
+ UserModel m = UserModel.GetCurrent ();
+ m.CheckIsSiteAdmin ();
+ Application app = new Application ();
+ app.Id = -1;
+ return View ("EditApplication", app);
+ }
+
+ public ActionResult EditApplication (int id)
+ {
+ UserModel m = UserModel.GetCurrent ();
+ m.CheckIsSiteAdmin ();
+ Application app = m.ServiceModel.GetApplication (id);
+ return View ("EditApplication", app);
+ }
+
+ [HttpPost]
+ public ActionResult UpdateApplication (Application app)
+ {
+ UserModel m = UserModel.GetCurrent ();
+ m.CheckIsSiteAdmin ();
+ if (app.Id != -1) {
+ Application capp = m.ServiceModel.GetApplication (app.Id);
+ capp.Name = app.Name;
+ capp.Subdomain = app.Subdomain;
+ capp.Platforms = app.Platforms;
+ m.ServiceModel.UpdateApplication (capp);
+ }
+ else {
+ app.Description = "<p>This is the home page of the add-in repository for " + app.Name + "</p><p>Click on the 'Edit Page' link to change the content of this welcome page</p>";
+ m.ServiceModel.CreateApplication (app);
+ }
+ return RedirectToAction ("Index");
+ }
+
public ActionResult UsersList ()
{
UserModel m = UserModel.GetCurrent ();
@@ -93,8 +93,8 @@ public ActionResult Authenticate (string returnUrl, string ticket)
else
realm = new Realm ("http://*." + host);
- IAuthenticationRequest req = openid.CreateRequest (Request.Form["openid_identifier"]);
-// IAuthenticationRequest req = openid.CreateRequest (Request.Form["openid_identifier"], realm);
+// IAuthenticationRequest req = openid.CreateRequest (Request.Form["openid_identifier"]);
+ IAuthenticationRequest req = openid.CreateRequest (Request.Form["openid_identifier"], realm);
OutgoingWebResponse res = req.RedirectingResponse;
return new InternalOutgoingWebResponseActionResult (res);
}
@@ -128,7 +128,10 @@ public ActionResult Authenticate (string returnUrl, string ticket)
// This is a new user, send them to a registration page
if (user == null) {
ViewData["openid"] = response.ClaimedIdentifier;
- return Redirect (string.Format ("~/User/register?openid={0}", Url.Encode (response.ClaimedIdentifier)));
+ if (Settings.Default.SupportsMultiApps)
+ return Redirect (string.Format ("~/home/User/register?openid={0}", Url.Encode (response.ClaimedIdentifier)));
+ else
+ return Redirect (string.Format ("~/User/register?openid={0}", Url.Encode (response.ClaimedIdentifier)));
}
Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay;
View
@@ -197,6 +197,7 @@
<Content Include="Views\SiteAdmin\Setup.aspx" />
<Content Include="Views\Home\Edit.aspx" />
<Content Include="Views\SiteAdmin\Log.aspx" />
+ <Content Include="Views\SiteAdmin\EditApplication.aspx" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
@@ -45,12 +45,12 @@ public class Application
[DataMember]
public string Subdomain { get; set; }
- public string AddingPackageSubextension {
+ public string AddinPackageSubextension {
get { return "monodevelop"; }
}
- public string AddingPackageExtension {
- get { return "." + AddingPackageSubextension + "-mpack"; }
+ public string AddinPackageExtension {
+ get { return "." + AddinPackageSubextension + "-mpack"; }
}
}
}
@@ -166,6 +166,11 @@ public void UpdateApplication (Application app)
{
db.UpdateObject (app);
}
+
+ public void CreateApplication (Application app)
+ {
+ db.InsertObject (app);
+ }
}
}
@@ -1,7 +1,9 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%
- if (Request.IsAuthenticated) {
- Cydin.Models.User CurrentUser = Cydin.Models.UserModel.GetCurrent ().User;
+ Cydin.Models.User CurrentUser = null;
+ if (Request.IsAuthenticated)
+ CurrentUser = Cydin.Models.UserModel.GetCurrent ().User;
+ if (CurrentUser != null) {
%>
<div class="usertext">
@@ -0,0 +1,42 @@
+<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Cydin.Models.Application>" %>
+
+<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
+ Edit Application
+</asp:Content>
+<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
+ <h2>Application</h2>
+ <%= Html.ValidationSummary("Edit was unsuccessful. Please correct the errors and try again.") %>
+ <% using (Html.BeginForm ("UpdateApplication","SiteAdmin")) { %>
+ <table width="600" cellpadding="5px">
+ <%= Html.Hidden ("Id", Model.Id) %>
+ <tr>
+ <td>Name:</td>
+ <td>
+ <%= Html.TextBox ("Name", Model.Name) %>
+ <%= Html.ValidationMessage ("Name", "*") %>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Supported Platforms:
+ </td>
+ <td>
+ <%= Html.TextBox ("Platforms", Model.Platforms, new { @class = "form-text", style = "width: 260px;" })%>
+ <%= Html.ValidationMessage ("Platforms", "*")%>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Subdomain:
+ </td>
+ <td>
+ <%= Html.TextBox ("Subdomain", Model.Subdomain, new { @class = "form-text", style = "width: 260px;" })%>
+ <%= Html.ValidationMessage ("Subdomain", "*")%>
+ </td>
+ </tr>
+ </table>
+ <br><br>
+ <input type="submit" value="Save" />
+ <input type="button" value="Cancel" onclick="window.location.href='/SiteAdmin'"/>
+ <% } %>
+</asp:Content>
@@ -42,15 +42,27 @@
<% } %>
</div>
<div id="tabs-2">
+ <%
+ var apps = Model.GetApplications ();
+ if (!apps.Any ())
+ Response.Write ("There are no applications defined.");
+ else { %>
<table>
- <tr><th>Application</th><th></th></tr>
- <% foreach (Application app in Model.GetApplications ()) { %>
+ <tr><th>Name</th><th>Subdomain</th><th>Platforms</th><th></th></tr>
+ <%
+ foreach (Application app in Model.GetApplications ()) { %>
<tr>
- <td> <%=app.Name%> </td>
+ <td> <%=Html.ActionLink (app.Name, "EditApplication", "SiteAdmin", new { id = app.Id }, null) %> </td>
+ <td> <%=app.Subdomain%> </td>
+ <td> <%=app.Platforms%> </td>
<td> <%=Html.ActionLink ("Delete", "DeleteApplication", "SiteAdmin", new { id = app.Id }, null) %> </td>
</tr>
- <% } %>
+ <% } } %>
</table>
+
+ <% if (Settings.Default.SupportsMultiApps || apps.Count() == 0) { %>
+ <p><%=Html.ActionLink ("Add new application", "NewApplication") %></p>
+ <% } %>
</div>
</div>
@@ -15,11 +15,11 @@
{
var sel = $("#operation-selector").attr("value");
if (sel == "1")
- $("#operation-selector-desc").text ("The site provides add-ins for a single application.");
+ $("#operation-selector-desc").text ("In Single Operation Mode, the site provides add-ins for a single application.");
else if (sel == "2")
- $("#operation-selector-desc").html ("Multiple applications are supported. Each application is identified by a subdomain in the url, for example: <b>monodevelop</b>.cydin.net");
+ $("#operation-selector-desc").html ("Using this mode, multiple applications are supported. Each application is identified by a subdomain in the url, for example: <b>monodevelop</b>.cydin.net");
else if (sel == "3")
- $("#operation-selector-desc").html ("Multiple applications are supported. Each application is identified by a path in the url, for example: cydin.net/<b>monodevelop</b>");
+ $("#operation-selector-desc").html ("Using this mode, multiple applications are supported. Each application is identified by a path in the url, for example: cydin.net/<b>monodevelop</b>");
}
</script>
<%

0 comments on commit 5619edb

Please sign in to comment.