@@ -95,10 +95,17 @@ sub get_edit_new_blog ($c) {
9595 $c -> stash-> {form_rss_url } = $blog -> rss_url;
9696 $c -> stash-> {form_tagline } = $blog -> tagline;
9797 $c -> stash-> {form_about } = $blog -> about;
98+ $c -> stash-> {form_adult } = $blog -> is_adult;
9899
99- # Make sure we have added the tags to the page.
100- push @{$c -> stash-> {tags }}, $c -> db-> resultset(' Tag' )-> all;
100+ my %seen = map { $_ -> tag_id => 1 } $blog -> search_related(' pending_blog_tag_maps' , {})-> all;
101+ foreach my $tag ( $c -> db-> resultset(' Tag' )-> all ) {
102+ push @{$c -> stash-> {tags }}, {
103+ id => $tag -> id,
104+ name => $tag -> name,
105+ checked => $seen {$tag -> id} ? 1 : 0,
106+ };
101107
108+ }
102109}
103110
104111sub post_edit_new_blog ($c ) {
@@ -116,17 +123,26 @@ sub post_edit_new_blog ($c) {
116123 $c -> stash-> {form_rss_url } = $c -> param(" rss_url" );
117124 $c -> stash-> {form_tagline } = $c -> param(" tagline" );
118125 $c -> stash-> {form_about } = $c -> param(" about" );
126+ $c -> stash-> {form_adult } = $c -> param(" is_adult" ) ? 1 : 0;
119127
120-
121- $blog -> title ( $c -> stash-> {form_title } );
122- $blog -> url ( $c -> stash-> {form_url } );
123- $blog -> img_url ( $c -> stash-> {form_img_url } );
124- $blog -> rss_url ( $c -> stash-> {form_rss_url } );
125- $blog -> tagline ( $c -> stash-> {form_tagline } );
126- $blog -> about ( $c -> stash-> {form_about } );
128+ $blog -> title ( $c -> stash -> { form_title } );
129+ $blog -> url ( $c -> stash-> {form_url } );
130+ $blog -> img_url ( $c -> stash-> {form_img_url } );
131+ $blog -> rss_url ( $c -> stash-> {form_rss_url } );
132+ $blog -> tagline ( $c -> stash-> {form_tagline } );
133+ $blog -> about ( $c -> stash-> {form_about } );
134+ $blog -> is_adult ( $c -> stash-> {form_adult } );
127135
128136 $blog -> update;
129137
138+ # Remove all tags, then add the tags we have set.
139+ $blog -> search_related(' pending_blog_tag_maps' )-> delete ;
140+ foreach my $tag_id ( @{$c -> every_param(' tags' )}) {
141+ $blog -> create_related(' pending_blog_tag_maps' , {
142+ tag_id => $tag_id ,
143+ });
144+ }
145+
130146 # Send the user back to the standard GET path.
131147 $c -> redirect_to( $c -> url_for( ' edit_new_blog' , id => $blog -> id ) );
132148
0 commit comments