@@ -89,7 +89,6 @@ sub post_new_blog ($c) {
8989 ),
9090 });
9191
92- $c -> minion-> enqueue( populate_blog_entires => [ $blog -> id, ' pending' ]);
9392 $c -> minion-> enqueue( populate_blog_screenshot => [ $blog -> id, ' pending' ]);
9493
9594 $c -> redirect_to( $c -> url_for( ' edit_new_blog' , id => $blog -> id ) );
@@ -98,8 +97,8 @@ sub post_new_blog ($c) {
9897sub get_edit_new_blog ($c ) {
9998 $c -> set_template( ' blog/new/item' );
10099
101- my $blog_id = $c -> stash-> {blog_id } = $c -> param(' id' );
102- my $blog = $c -> stash-> {blog_obj } = $c -> db-> resultset(' PendingBlog' )-> find( $blog_id );
100+ my $blog_id = $c -> stash-> {blog_id } = $c -> param(' id' );
101+ my $blog = $c -> stash-> {blog } = $c -> db-> resultset(' PendingBlog' )-> find( $blog_id );
103102
104103
105104 # Populate the form with the current values.
@@ -120,12 +119,21 @@ sub get_edit_new_blog ($c) {
120119 };
121120
122121 }
122+
123+ foreach my $post ( $blog -> search_related(' pending_blog_entries' )-> all ) {
124+ push @{$c -> stash-> {posts }}, {
125+ title => $post -> title,
126+ url => $post -> url,
127+ date => $post -> publish_date,
128+ };
129+ }
130+
123131}
124132
125133sub post_edit_new_blog ($c ) {
126134
127- my $blog_id = $c -> stash-> {blog_id } = $c -> param(' id' );
128- my $blog = $c -> stash-> {blog_obj } = $c -> db-> resultset(' PendingBlog' )-> find( $blog_id );
135+ my $blog_id = $c -> stash-> {blog_id } = $c -> param(' id' );
136+ my $blog = $c -> stash-> {blog } = $c -> db-> resultset(' PendingBlog' )-> find( $blog_id );
129137
130138
131139 # TODO: This section should be guarded by checking that the user
@@ -147,6 +155,9 @@ sub post_edit_new_blog ($c) {
147155
148156 $blog -> update;
149157
158+ # Get Posts from RSS Feed.
159+ $c -> minion-> enqueue( populate_blog_entries => [ $blog -> id, ' pending' ]);
160+
150161 # Remove all tags, then add the tags we have set.
151162 $blog -> search_related(' pending_blog_tag_maps' )-> delete ;
152163 foreach my $tag_id ( @{$c -> every_param(' tags' )}) {
@@ -173,16 +184,16 @@ sub post_publish_new_blog ($c) {
173184 });
174185
175186 my @tags = $pb -> search_related(' pending_blog_tag_maps' )-> all;
176-
177187 foreach my $tag ( @tags ) {
178188 $blog -> create_related(' blog_tag_maps' , {
179189 tag_id => $tag -> tag_id,
180190 });
181191 $tag -> delete ;
182192 }
193+ $pb -> search_related(' pending_blog_entries' )-> delete ;
183194 $pb -> delete ;
184195
185- $c -> minion-> enqueue( populate_blog_entires => [ $blog -> id, ' prod' ]);
196+ $c -> minion-> enqueue( populate_blog_entries => [ $blog -> id, ' prod' ]);
186197 $c -> minion-> enqueue( populate_blog_screenshot => [ $blog -> id, ' prod' ]);
187198
188199 $c -> redirect_to( $c -> url_for( ' view_blog' , slug => $blog -> slug ) );
0 commit comments