Example #1
0
 public function action_create()
 {
     $project_input = Input::get('project');
     if ($project_input["project_type_id"] == "Other") {
         if (!Input::get('new_project_type_name')) {
             Session::flash('errors', array(__("r.flashes.new_project_no_project_type")));
             return Redirect::to_route('new_projects')->with_input();
         } elseif ($existing_project_type = ProjectType::where_name(Input::get('new_project_type_name'))->first()) {
             $project_input["project_type_id"] = $existing_project_type->id;
         } else {
             $project_type = new ProjectType(array('name' => Input::get('new_project_type_name')));
             $project_type->save();
             $project_input["project_type_id"] = $project_type->id;
         }
     }
     $project = new Project($project_input);
     $dt = new \DateTime($project_input["proposals_due_at"], new DateTimeZone('America/New_York'));
     // if user doesn't specify a date, set it to 1 month from now
     if (!$project_input["proposals_due_at"]) {
         $dt->modify('+1 month');
     }
     $dt->setTimeZone(new DateTimeZone('UTC'));
     $project->proposals_due_at = $dt;
     if ($project->validator()->passes()) {
         $project->save();
         $project->officers()->attach(Auth::officer()->id, array('owner' => true));
         return Redirect::to_route('project_template', array($project->id));
     } else {
         Session::flash('errors', $project->validator()->errors->all());
         return Redirect::to_route('new_projects')->with_input();
     }
 }
Example #2
0
 public static function project($fork_from_project_id)
 {
     $faker = Faker\Factory::create();
     $original_project = Project::find($fork_from_project_id);
     $due_at = new \DateTime();
     $due_at->setTimestamp(rand(1346475600, 1364792400));
     $p = new Project(array('project_type_id' => $original_project->project_type_id, 'title' => self::$project_titles[array_rand(self::$project_titles)], 'agency' => self::$agencies[array_rand(self::$agencies)], 'office' => self::$offices[array_rand(self::$offices)], 'zipcode' => self::$offices[array_rand(self::$zipcodes)], 'background' => $faker->paragraph, 'sections' => $original_project->sections, 'variables' => $original_project->variables, 'deliverables' => $original_project->deliverables, 'proposals_due_at' => $due_at));
     if (rand(0, 1) == 1) {
         $p->public = true;
         $p->recommended = rand(0, 1);
         $p->fork_count = rand(0, 8);
     }
     $p->forked_from_project_id = $original_project->id;
     $p->posted_to_fbo_at = rand(0, 1) == 0 ? new \DateTime() : null;
     $p->save();
     $p->officers()->attach(Officer::first()->id, array('owner' => true));
     return $p;
 }
Example #3
0
File: seed.php Project: ajb/rfpez
 private function minimal_data()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 5; $i++) {
         Factory::vendor();
     }
     for ($i = 0; $i < 5; $i++) {
         Factory::officer();
     }
     $project_type_1 = ProjectType::first();
     // Create project sections
     $section1 = ProjectSection::create(array('section_category' => 'Deliverables', 'title' => 'Information Architecture', 'public' => true, 'body' => 'Information architecture (IA) and initial site map for the redesigned {{WEBSITE}} site. This IA and site map will be used so copy can be revised and/or developed in-house while the contractor is in the process of executing other deliverable products. Note the IA and site map will only include content/sites currently in the {{WEBSITE}} infrastructure.'));
     $section2 = ProjectSection::create(array('section_category' => 'Deliverables', 'title' => 'Page Templating', 'public' => true, 'body' => 'Complete redesign of {{WEBSITE}} and templates for outreach materials. This includes the complete website, features, applications, blog, social media, mobile, email and newsletters, and any items deemed best to connect with the audiences identified in Deliverable Product #1.'));
     $section3 = ProjectSection::create(array('section_category' => 'Objectives', 'title' => 'Increased Visibility', 'public' => true, 'body' => $faker->paragraph));
     // Link project sections to api project type
     $project_type_1->project_sections()->sync(array($section1->id, $section2->id, $section3->id));
     // Create first project
     $project = new Project(array('project_type_id' => $project_type_1->id, 'title' => 'API for SBA.gov Dynamic Small Business Search', 'agency' => 'Small Business Administration', 'office' => 'Office of Innovation and Research', 'recommended' => true, 'public' => true, 'background' => $faker->paragraph, 'sections' => array($section1->id, $section2->id, $section3->id), 'variables' => array('WEBSITE' => 'api.dsbs.sba.gov'), 'deliverables' => array('Information Architecture' => '1/1/13', 'Page Templating' => '2/8/13'), 'proposals_due_at' => new \DateTime('12/31/2012')));
     $project->posted_to_fbo_at = new \DateTime();
     $project->save();
     // ...And give it to officer1
     $project->officers()->attach(Officer::first()->id, array('owner' => true));
 }