Show thingy controls when maxEntriesPerUser is reached. Fixes bug #10950.
This commit is contained in:
parent
4be50c6cae
commit
8395d090fa
3 changed files with 64 additions and 11 deletions
|
|
@ -46,6 +46,7 @@
|
||||||
- fixed #10924: Calendar event in last day of month does not display in month/day view
|
- fixed #10924: Calendar event in last day of month does not display in month/day view
|
||||||
- fixed #10901: Calendar More Button/Display Box IE8 error.
|
- fixed #10901: Calendar More Button/Display Box IE8 error.
|
||||||
- fixed #10954: DataForm fails silently
|
- fixed #10954: DataForm fails silently
|
||||||
|
- fixed #10950: Thingy
|
||||||
|
|
||||||
7.7.19
|
7.7.19
|
||||||
- fixed #10838: Forwarded forum post email to new CS adds reply to original thread
|
- fixed #10838: Forwarded forum post email to new CS adds reply to original thread
|
||||||
|
|
|
||||||
|
|
@ -2425,10 +2425,6 @@ sub editThingData {
|
||||||
|
|
||||||
return $session->privilege->insufficient() unless $canEditThingData;
|
return $session->privilege->insufficient() unless $canEditThingData;
|
||||||
|
|
||||||
if($thingDataId eq 'new' && $self->hasEnteredMaxPerUser($thingId)){
|
|
||||||
return $i18n->get("has entered max per user message");
|
|
||||||
}
|
|
||||||
|
|
||||||
my (%thingData, $fields,@field_loop,$fieldValue, $privilegedGroup);
|
my (%thingData, $fields,@field_loop,$fieldValue, $privilegedGroup);
|
||||||
my $var = $self->get;
|
my $var = $self->get;
|
||||||
my $url = $self->getUrl;
|
my $url = $self->getUrl;
|
||||||
|
|
@ -2510,6 +2506,14 @@ sub editThingData {
|
||||||
$var->{"form_submit"} = WebGUI::Form::submit($self->session,{value => $thingProperties->{saveButtonLabel}});
|
$var->{"form_submit"} = WebGUI::Form::submit($self->session,{value => $thingProperties->{saveButtonLabel}});
|
||||||
$var->{"form_end"} = WebGUI::Form::formFooter($self->session);
|
$var->{"form_end"} = WebGUI::Form::formFooter($self->session);
|
||||||
$self->appendThingsVars($var, $thingId);
|
$self->appendThingsVars($var, $thingId);
|
||||||
|
|
||||||
|
if($thingDataId eq 'new' && $self->hasEnteredMaxPerUser($thingId)){
|
||||||
|
delete $var->{form_start};
|
||||||
|
delete $var->{form_end};
|
||||||
|
delete $var->{form_submit};
|
||||||
|
delete $var->{field_loop};
|
||||||
|
$var->{editInstructions} = $i18n->get("has entered max per user message");
|
||||||
|
}
|
||||||
return $self->processTemplate($var,$thingProperties->{editTemplateId});
|
return $self->processTemplate($var,$thingProperties->{editTemplateId});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,27 @@ use lib "$FindBin::Bin/../../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::PseudoRequest;
|
use Test::More tests => 22; # increment this value for each test you create
|
||||||
use Test::More tests => 17; # increment this value for each test you create
|
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
use JSON;
|
use JSON;
|
||||||
use WebGUI::Asset::Wobject::Thingy;
|
use WebGUI::Asset::Wobject::Thingy;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
# Do our work in the import node
|
# Do our work in the import node
|
||||||
my $node = WebGUI::Asset->getImportNode($session);
|
my $node = WebGUI::Asset->getImportNode($session);
|
||||||
|
|
||||||
|
my $templateId = 'THING_EDIT_TEMPLATE___';
|
||||||
|
my $templateMock = Test::MockObject->new({});
|
||||||
|
$templateMock->set_isa('WebGUI::Asset::Template');
|
||||||
|
$templateMock->set_always('getId', $templateId);
|
||||||
|
my $templateVars;
|
||||||
|
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||||
|
|
||||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||||
$versionTag->set({name=>"Thingy Test"});
|
$versionTag->set({name=>"Thingy Test"});
|
||||||
|
WebGUI::Test->tagsToRollback($versionTag);
|
||||||
my $thingy = $node->addChild({className=>'WebGUI::Asset::Wobject::Thingy'});
|
my $thingy = $node->addChild({className=>'WebGUI::Asset::Wobject::Thingy'});
|
||||||
|
|
||||||
# Test for a sane object type
|
# Test for a sane object type
|
||||||
|
|
@ -198,15 +206,16 @@ my $copyThingId = $thingy->duplicateThing($thingId);
|
||||||
|
|
||||||
$isValidId = $session->id->valid($copyThingId);
|
$isValidId = $session->id->valid($copyThingId);
|
||||||
|
|
||||||
is($isValidId,1,"duplicating a Thing: duplicateThing returned a valid id: ".$copyThingId);
|
ok($isValidId, "duplicating a Thing: duplicateThing returned a valid id: ".$copyThingId);
|
||||||
|
|
||||||
# Test adding, editing, getting and deleting thing data
|
# Test adding, editing, getting and deleting thing data
|
||||||
|
|
||||||
my ($newThingDataId,$errors) = $thingy->editThingDataSave($thingId,'new',{"field_".$fieldId => 'test value'});
|
my ($newThingDataId,$errors) = $thingy->editThingDataSave($thingId,'new',{"field_".$fieldId => 'test value'});
|
||||||
|
ok( ! $thingy->hasEnteredMaxPerUser($thingId), 'hasEnteredMaxPerUser: returns false when maxEntriesPerUser=0 and 1 entry added');
|
||||||
|
|
||||||
my $isValidThingDataId = $session->id->valid($newThingDataId);
|
my $isValidThingDataId = $session->id->valid($newThingDataId);
|
||||||
|
|
||||||
is($isValidId,1,"Adding thing data: editFieldSave returned a valid id: ".$newThingDataId);
|
ok($isValidThingDataId, "Adding thing data: editFieldSave returned a valid id: ".$newThingDataId);
|
||||||
|
|
||||||
my $viewThingVars = $thingy->getViewThingVars($thingId,$newThingDataId);
|
my $viewThingVars = $thingy->getViewThingVars($thingId,$newThingDataId);
|
||||||
|
|
||||||
|
|
@ -289,9 +298,48 @@ cmp_deeply(
|
||||||
'Getting thing data as JSON after deleting: www_viewThingDataViaAjax returns correct message.'
|
'Getting thing data as JSON after deleting: www_viewThingDataViaAjax returns correct message.'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
($newThingDataId,$errors) = $thingy->editThingDataSave($thingId,'new',{"field_".$fieldId => 'second test value'});
|
||||||
|
|
||||||
END {
|
my %otherThingProperties = %thingProperties;
|
||||||
# Clean up after thy self
|
$otherThingProperties{maxEntriesPerUser} = 1;
|
||||||
$versionTag->rollback();
|
$otherThingProperties{editTemplateId } = $templateId;
|
||||||
|
my $otherThingId = $thingy->addThing(\%otherThingProperties, 0);
|
||||||
|
my $otherFieldId = $thingy->addField(\%fieldProperties, 0);
|
||||||
|
ok( ! $thingy->hasEnteredMaxPerUser($otherThingId), 'hasEnteredMaxPerUser: returns false with no data entered');
|
||||||
|
|
||||||
|
my @edit_thing_form_fields = qw/form_start form_end form_submit field_loop/;
|
||||||
|
|
||||||
|
{
|
||||||
|
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||||
|
$thingy->editThingData($otherThingId);
|
||||||
|
my %miniVars;
|
||||||
|
@miniVars{@edit_thing_form_fields} = @{ $templateVars }{ @edit_thing_form_fields };
|
||||||
|
cmp_deeply(
|
||||||
|
\%miniVars,
|
||||||
|
{
|
||||||
|
form_start => ignore,
|
||||||
|
form_end => ignore,
|
||||||
|
form_submit => ignore,
|
||||||
|
field_loop => ignore,
|
||||||
|
},
|
||||||
|
'thing edit form variables exist, because max entries not reached yet'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$thingy->editThingDataSave($otherThingId, 'new', {"field_".$otherFieldId => 'other test value'} );
|
||||||
|
ok( $thingy->hasEnteredMaxPerUser($otherThingId), '... returns true with one row entered, and maxEntriesPerUser=1');
|
||||||
|
|
||||||
|
{
|
||||||
|
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||||
|
$thingy->editThingData($otherThingId);
|
||||||
|
my %miniVars;
|
||||||
|
@miniVars{@edit_thing_form_fields} = @{ $templateVars }{ @edit_thing_form_fields };
|
||||||
|
my $existance = 0;
|
||||||
|
foreach my $tmplVar (@edit_thing_form_fields) {
|
||||||
|
$existance ||= exists $templateVars->{$tmplVar}
|
||||||
|
}
|
||||||
|
ok(
|
||||||
|
! $existance,
|
||||||
|
'thing edit form variables do not exist, because max entries was reached'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue