Permalink
Browse files

Renamed suggest a place to add a place.

Fixed A-Z history navigation.
Made check for duplicates on add a place prettier and added a close button.
  • Loading branch information...
dblock committed Oct 8, 2009
1 parent 12df898 commit f87bb7de1d888d19095e07e3aa79ab462bcaa19c
View
@@ -278,7 +278,7 @@ To post an event follow these simple steps.
<li>Before posting events make sure to double-check your timezone in account preferences. All specified times are set in your local
timezone and users in other timezones will see time adjusted to their location. Note that since events are attached to places they are
geographically restricted and a user in Seattle typically doesn't see events in New York unless he explicitly chooses to do so.
- <li>Follow the <em>suggest an event</em> link.
+ <li>Follow the <em>add an event</em> link.
<li>Enter the event <em>name</em>, choose an event <em>type</em> and enter a short description. The description may contain links or
limited HTML content.
<li>By default you will schedule a <em>one-time</em> event. That is, an event that occurs once. You must choose the <em>start and end
@@ -541,7 +541,7 @@ public override void Delete(ManagedSecurityContext sec)
public bool CanWrite(int accountid)
{
- // person suggesting a place can write
+ // person adding a place can write
if (mInstance.Account.Id == accountid)
return true;
@@ -0,0 +1,87 @@
+using System;
+using NUnit.Framework;
+using SnCore.Data;
+using NHibernate;
+using SnCore.Data.Tests;
+using System.Collections;
+using SnCore.Services;
+using System.Collections.Specialized;
+using System.Collections.Generic;
+using System.Text;
+using NHibernate.Expression;
+
+namespace SnCore.Stress.Tests
+{
+ [TestFixture]
+ public class CreatePlacesStressTest : NHibernateTest
+ {
+ public CreatePlacesStressTest()
+ {
+
+ }
+
+ [Test]
+ public void Create100Places()
+ {
+ CreateManyPlaces(100);
+ }
+
+ [Test]
+ public void Create1000Places()
+ {
+ CreateManyPlaces(1000);
+ }
+
+ [Test]
+ public void Create10000Places()
+ {
+ CreateManyPlaces(10000);
+ }
+
+ public void CreateManyPlaces(int count)
+ {
+ Random r = new Random();
+ ManagedSecurityContext sec = ManagedAccount.GetAdminSecurityContext(Session);
+
+ // country
+ TransitCountry t_country = new TransitCountry();
+ t_country.Name = Guid.NewGuid().ToString();
+ ManagedCountry country = new ManagedCountry(Session);
+ country.CreateOrUpdate(t_country, sec);
+ // state
+ TransitState t_state = new TransitState();
+ t_state.Name = Guid.NewGuid().ToString();
+ t_state.Country = t_country.Name;
+ ManagedState state = new ManagedState(Session);
+ state.CreateOrUpdate(t_state, sec);
+ // city
+ TransitCity t_city = new TransitCity();
+ t_city.Name = Guid.NewGuid().ToString();
+ t_city.State = t_state.Name;
+ t_city.Country = t_country.Name;
+ ManagedCity city = new ManagedCity(Session);
+ city.CreateOrUpdate(t_city, sec);
+ // place type
+ TransitPlaceType t_placetype = new TransitPlaceType();
+ t_placetype.Name = Guid.NewGuid().ToString();
+ ManagedPlaceType placetype = new ManagedPlaceType(Session);
+ placetype.CreateOrUpdate(t_placetype, sec);
+
+ for (int i = 0; i < count; i++)
+ {
+ TransitPlace t_place = new TransitPlace();
+ t_place.Name = Guid.NewGuid().ToString();
+ t_place.AccountId = sec.Account.Id;
+ t_place.City = t_city.Name;
+ t_place.Country = t_country.Name;
+ t_place.State = t_state.Name;
+ t_place.Street = string.Format("{0} {1} St.", r.Next(), Guid.NewGuid().ToString());
+ t_place.Zip = r.Next().ToString();
+ t_place.Type = t_placetype.Name;
+
+ ManagedPlace place = new ManagedPlace(Session);
+ place.CreateOrUpdate(t_place, sec);
+ }
+ }
+ }
+}
@@ -132,6 +132,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="CreateAccountsStressTest.cs" />
+ <Compile Include="CreatePlacesStressTests.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
@@ -18,10 +18,9 @@ public partial class AToZControl : Control
protected void Page_Load(object sender, EventArgs e)
{
-
}
- public Char SelectedValue
+ public Char SelectedValue
{
get
{
@@ -60,6 +59,37 @@ void AddButton(char c)
link.Command += new CommandEventHandler(link_Command);
divatoz.Controls.Add(link);
}
+ public bool SelectIfChar(string s)
+ {
+ return SelectIfChar(s, true);
+ }
+
+ public void ClearSelection()
+ {
+ EnableDisableSelectedValue(true);
+ SelectedValue = default(char);
+ }
+
+ /// <summary>
+ /// Clear the selection and select if the target is a single character.
+ /// </summary>
+ /// <param name="s"></param>
+ /// <returns></returns>
+ public bool SelectIfChar(string s, bool alwaysSelect)
+ {
+ if (s.Length == 1)
+ {
+ ClearSelection();
+ SelectedValue = s[0];
+ return true;
+ }
+ else if (alwaysSelect)
+ {
+ ClearSelection();
+ }
+
+ return false;
+ }
protected override void OnPreRender(EventArgs e)
{
@@ -100,7 +100,7 @@
<table class="sncore_inner_table" width="95%">
<tr>
<td style="font-size: smaller; text-align: right;">
- <% Response.Write(SuggestedBy); %>
+ <% Response.Write(AddedBy); %>
</td>
<td style="font-size: smaller; text-align: right;">
<a href="AccountEventEdit.aspx">&#187; post an event</a>
@@ -53,7 +53,7 @@ public TransitPlace AccountEventPlace
}
}
- public string SuggestedBy
+ public string AddedBy
{
get
{
@@ -18,27 +18,91 @@
public partial class AccountFeedsView : Page
{
- public AccountFeedsView()
+ public class LocationWithOptionsEventArgs : LocationEventArgs
{
- mIsMobileEnabled = true;
+ private string mPicturesOnly;
+
+ public string PicturesOnly
+ {
+ get
+ {
+ return mPicturesOnly;
+ }
+ set
+ {
+ mPicturesOnly = value;
+ }
+ }
+
+ public LocationWithOptionsEventArgs(HttpRequest request)
+ : base(request)
+ {
+ mPicturesOnly = request["pictures"];
+ }
+
+ public LocationWithOptionsEventArgs(NameValueCollection coll)
+ : base(coll)
+ {
+ mPicturesOnly = coll["pictures"];
+ }
+ }
+
+ public class LocationSelectorWithOptions : LocationSelectorCountryStateCity
+ {
+ private CheckBox mPicturesOnly;
+
+ public LocationSelectorWithOptions(
+ Page page,
+ bool empty,
+ DropDownList country,
+ DropDownList state,
+ DropDownList city,
+ CheckBox picturesonly)
+ :
+ base(page, empty, country, state, city)
+ {
+ mPicturesOnly = picturesonly;
+ }
+
+ public bool SelectLocation(object sender, LocationWithOptionsEventArgs e)
+ {
+ bool result = base.SelectLocation(sender, e);
+
+ if (e.Clear || (mPicturesOnly != null && !string.IsNullOrEmpty(e.PicturesOnly)))
+ {
+ bool picturesonly = false;
+ if (bool.TryParse(e.PicturesOnly, out picturesonly))
+ {
+ mPicturesOnly.Checked = picturesonly;
+ result = true;
+ }
+ }
+
+ return result;
+ }
}
- private LocationSelectorCountryStateCity mLocationSelector = null;
+ private LocationSelectorWithOptions mLocationSelector = null;
- public LocationSelectorCountryStateCity LocationSelector
+ public LocationSelectorWithOptions LocationSelector
{
get
{
if (mLocationSelector == null)
{
- mLocationSelector = new LocationSelectorCountryStateCity(
- this, true, inputCountry, inputState, inputCity);
+ mLocationSelector = new LocationSelectorWithOptions(
+ this, true, inputCountry, inputState, inputCity, checkboxPicturesOnly);
}
return mLocationSelector;
}
}
+ public AccountFeedsView()
+ {
+ mIsMobileEnabled = true;
+ }
+
public void Page_Load(object sender, EventArgs e)
{
gridManage.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);
@@ -115,7 +179,18 @@ void History_Navigate(object sender, HistoryEventArgs e)
{
if (e.State.HasKeys())
{
+ LocationWithOptionsEventArgs l_args = new LocationWithOptionsEventArgs(e.State);
+ l_args.Clear = true;
+ LocationSelector.SelectLocation(sender, l_args);
gridManage.CurrentPageIndex = int.Parse(e.State["page"]);
+ inputName.Text = e.State["name"];
+ atoz.SelectIfChar(inputName.Text);
+ }
+ else
+ {
+ LocationSelector.ClearSelection();
+ inputName.Text = string.Empty;
+ atoz.ClearSelection();
}
gridManage_OnGetDataSource(sender, e);
gridManage.DataBind();
@@ -16,8 +16,8 @@
</div>
<div class="sncore_h2sub">
<asp:HyperLink ID="linkAccount" runat="server" Text="&#187; Back" />
+ <a href="PlaceEdit.aspx">&#187; Add New</a>
<a href="PlacesView.aspx">&#187; All Places</a>
- <a href="PlaceEdit.aspx">&#187; Suggest a Place</a>
</div>
</td>
<td>
@@ -8,12 +8,12 @@
<SnCore:Title ID="titlePlaces" Text="My Places" runat="server">
<Template>
<div class="sncore_title_paragraph">
- <a href="PlaceEdit.aspx">Suggest a new place</a> for everybody to see. Upload pictures and post reviews.
+ <a href="PlaceEdit.aspx">Add</a> a new place for everybody to see. Upload pictures and post reviews.
</div>
</Template>
</SnCore:Title>
<div class="sncore_createnew">
- <a href="PlaceEdit.aspx">&#187; Suggest a New Place</a>
+ <a href="PlaceEdit.aspx">&#187; Add New Place</a>
<a href="AccountPlaceChangeRequestsManage.aspx">&#187; Change Requests</a>
</div>
<asp:UpdatePanel ID="panelGrid" runat="server" UpdateMode="Always">
@@ -13,7 +13,7 @@
</div>
</Template>
</SnCore:Title>
- <asp:HyperLink ID="linkSuggest" Text="&#187; Suggest a New Place" CssClass="sncore_createnew" NavigateUrl="PlaceEdit.aspx"
+ <asp:HyperLink ID="linkAdd" Text="&#187; Add New Place" CssClass="sncore_createnew" NavigateUrl="PlaceEdit.aspx"
runat="server" />
<asp:UpdatePanel ID="panelGrid" runat="server" UpdateMode="Always">
<ContentTemplate>
@@ -159,11 +159,15 @@ void History_Navigate(object sender, HistoryEventArgs e)
LocationSelector.SelectLocation(sender, l_args);
gridManage.CurrentPageIndex = int.Parse(e.State["page"]);
inputName.Text = e.State["name"];
- if (inputName.Text.Length == 1)
- {
- atoz.SelectedValue = inputName.Text[0];
- }
+ atoz.SelectIfChar(inputName.Text);
}
+ else
+ {
+ LocationSelector.ClearSelection();
+ inputName.Text = string.Empty;
+ atoz.ClearSelection();
+ }
+
gridManage_OnGetDataSource(sender, e);
gridManage.DataBind();
}
View
@@ -71,7 +71,7 @@
<td>
<div class="sncore_link">
<a href="PlacesView.aspx">&#187; all places</a>
- <a href="PlaceEdit.aspx">&#187; suggest a place</a>
+ <a href="PlaceEdit.aspx">&#187; add a new place</a>
</div>
<div class="sncore_link">
<a href="FeaturedPlacesView.aspx">&#187; previously featured</a>
Oops, something went wrong.

0 comments on commit f87bb7d

Please sign in to comment.