Changeset 36
- Timestamp:
- 02/17/07 19:28:57 (2 years ago)
- Files:
-
- trunk/Memories.pm (modified) (2 diffs)
- trunk/Memories/Photo.pm (modified) (1 diff)
- trunk/templates/photo/quarantine (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Memories.pm
r31 r36 2 2 use strict; 3 3 our $VERSION = "1.2"; 4 use Maypole::Application qw(Upload Authentication::UserSessionCookie -Debug);4 use Maypole::Application qw(Upload Authentication::UserSessionCookie); 5 5 use HTML::TagCloud; 6 6 use URI; … … 93 93 $r->get_user; 94 94 if (!$r->user and $self->path =~ /upload/) { $r->template("login"); } 95 # Don't let 'em go until they've fixed it 96 warn "Quarantine is : ".$r->session->{quarantined}; 97 if ($r->session->{quarantined} and $self->path !~ /js$/) { 98 $r->table("photo"); $r->action("quarantine"); 99 $r->model_class("Memories::Photo"); 100 } 95 101 return OK; 96 102 } trunk/Memories/Photo.pm
r34 r36 49 49 my $upload = $r->{ar}->upload("photo"); 50 50 # Check $self->type 51 my @photos = $self->upload_jpeg($upload->tempname, ($r->params->{title}||basename($upload->filename)), $r->params->{tags}, $r);51 my @photos = ($self->upload_jpeg($upload->tempname, ($r->params->{title}||basename($upload->filename)), $r->params->{tags}, $r)); 52 52 my @quarantined = grep { !$_->tags } @photos; 53 warn "Quarantined these photos: ".join(",", map {$_->id} @quarantined); 53 54 # Set it up to go again 55 if (@quarantined) { 56 $r->{session}{quarantined} = join ",", sort map { $_->id} @quarantined; 57 warn "Setting quarantineined to: ".( join ",", sort map { $_->id} @quarantined); 58 $r->objects(\@quarantined); 59 $r->template("quarantine"); 60 return; 61 } 54 62 $r->objects(\@photos); 55 $r->template("view"); 63 if (@photos > 1) { $r->template("list") } 64 else { $r->template("view"); } 56 65 $r->message("Thanks for the upload!"); 57 # Deal with the quarantined 66 } 67 68 sub quarantine :Exported { 69 my ($self, $r) = @_; 70 my @quarantined = split /,/, $r->{session}{quarantined}; 71 my %q = map { $_ => 1 } @quarantined; 72 warn "Before we had these quarantined: @{[ keys %q ]}"; 73 for (map /(\d+)/,grep /tags\d+/, keys %{$r->{params}}) { 74 my $tags = $r->{params}{"tags$_"}; 75 warn "Got tags for $_: <$tags>"; 76 next unless $tags; 77 if (my $photo = $self->retrieve($_)) { 78 $photo->add_tags($tags); 79 delete $q{$_}; 80 } 81 } 82 $r->{session}{quarantined} = join ",", sort keys %q; 83 warn "After, we have these quarantined: @{[ keys %q ]}"; 84 warn "And we set session to $r->{session}{quarantined}"; 85 if (!$r->{session}{quarantined}) { 86 $r->template("list"); 87 $r->objects([ map { $self->retrieve($_) } @quarantined ]); 88 } else { 89 $r->objects([ map { $self->retrieve($_) } sort keys %q ]); 90 } 58 91 } 59 92 60 93 sub upload_jpeg { 61 94 my ($self, $filename, $title, $tags, $r) = @_; 62 my $quarantine;63 95 my $photo = $self->create({ 64 96 uploader => $r->user,
