Browse files

Thingy - handle maxEntries better on defaultView

* Set Default View to "Add Thing" and "Max entries per user" to
  something non-zero (like "1").
  Then add enough rows to reach the limit.
* Henceforth, when you try to View the Thing, you will be told:
  "You have reached the maximum number of entries".

Seeing as you didn't actively try to add a row, this is a bit

A more friendly course of action, in my opinion, is to behave as
if the Default View is set to Search Thing when the max rows limit
is reached.
  • Loading branch information...
1 parent 98f3288 commit 46ffb6bd997b0e2f560714c8448324811ca94b72 @patspam patspam committed Jul 13, 2009
Showing with 12 additions and 3 deletions.
  1. +12 −3 lib/WebGUI/Asset/Wobject/
15 lib/WebGUI/Asset/Wobject/
@@ -1503,11 +1503,20 @@ sub view {
my $thingProperties = $self->getThing($defaultThingId);
if ($defaultView eq "searchThing"){
return $i18n->get("no permission to search") if( ! $self->canSearch($defaultThingId, $thingProperties));
- return $self->search($defaultThingId,$thingProperties)
+ return $self->search($defaultThingId,$thingProperties);
elsif ($defaultView eq "addThing"){
return $i18n->get("no permission to edit") if( ! $self->canEditThingData($defaultThingId, "new", $thingProperties));
- return $self->editThingData($defaultThingId,"new", $thingProperties);
+ # If max entries added and we did nothing, the user will see a "max entries already added" error
+ # which isn't very nice since they didn't actively try to add something - so be nice and behave
+ # as if defaultView set to searchThing in this case
+ if ($self->hasEnteredMaxPerUser($defaultThingId)) {
+ return $i18n->get("no permission to search") if( ! $self->canSearch($defaultThingId, $thingProperties));
+ return $self->search($defaultThingId,$thingProperties);
+ } else {
+ return $self->editThingData($defaultThingId,"new", $thingProperties);
+ }
return $self->processTemplate($var, undef, $self->{_viewTemplate});
@@ -3013,7 +3022,7 @@ sub www_manage {
# set the url for the view icon to the things default view
my $viewParams;
- if ($thing->{defaultView} eq "addThing") {
+ if ($thing->{defaultView} eq "addThing" && !$self->hasEnteredMaxPerUser($thing->{thingId})) {
$viewParams = 'func=editThingData;thingId='.$thing->{thingId}.';thingDataId=new';

0 comments on commit 46ffb6b

Please sign in to comment.