Author: sevein
Date: Tue Jul 12 11:24:09 2011
New Revision: 9298

Log:
Split accession and deaccession into two separate modules

Added:
   
trunk/plugins/qtAccessionPlugin/modules/deaccession/actions/deleteAction.class.php
      - copied unchanged from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/actions/deleteDeaccessionAction.class.php
   
trunk/plugins/qtAccessionPlugin/modules/deaccession/actions/editAction.class.php
      - copied unchanged from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/actions/editDeaccessionAction.class.php
   
trunk/plugins/qtAccessionPlugin/modules/deaccession/actions/indexAction.class.php
      - copied unchanged from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/actions/indexDeaccessionAction.class.php
   
trunk/plugins/qtAccessionPlugin/modules/deaccession/templates/deleteSuccess.php
      - copied unchanged from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/templates/deleteDeaccessionSuccess.php
   trunk/plugins/qtAccessionPlugin/modules/deaccession/templates/editSuccess.php
      - copied unchanged from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/templates/editDeaccessionSuccess.php
   
trunk/plugins/qtAccessionPlugin/modules/deaccession/templates/indexSuccess.php
      - copied unchanged from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/templates/indexDeaccessionSuccess.php
Deleted:
   
trunk/plugins/qtAccessionPlugin/modules/accession/actions/deleteDeaccessionAction.class.php
   
trunk/plugins/qtAccessionPlugin/modules/accession/actions/editDeaccessionAction.class.php
   
trunk/plugins/qtAccessionPlugin/modules/accession/actions/indexDeaccessionAction.class.php
   
trunk/plugins/qtAccessionPlugin/modules/accession/templates/deleteDeaccessionSuccess.php
   
trunk/plugins/qtAccessionPlugin/modules/accession/templates/editDeaccessionSuccess.php
   
trunk/plugins/qtAccessionPlugin/modules/accession/templates/indexDeaccessionSuccess.php

Copied: 
trunk/plugins/qtAccessionPlugin/modules/deaccession/actions/deleteAction.class.php
 (from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/actions/deleteDeaccessionAction.class.php)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/deaccession/actions/deleteAction.class.php
  Tue Jul 12 11:24:09 2011        (r9298, copy of r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/actions/deleteDeaccessionAction.class.php)
@@ -0,0 +1,43 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class AccessionDeleteDeaccessionAction extends sfAction
+{
+  public function execute($request)
+  {
+    $this->form = new sfForm;
+
+    $this->resource = $this->getRoute()->resource;
+
+    // Check user authorization
+    if (!QubitAcl::check($this->resource, 'delete'))
+    {
+      QubitAcl::forwardUnauthorized();
+    }
+
+    if ($request->isMethod('delete'))
+    {
+      $accession = $this->resource->accession;
+
+      $this->resource->delete();
+
+      $this->redirect(array($accession, 'module' => 'accession'));
+    }
+  }
+}

Copied: 
trunk/plugins/qtAccessionPlugin/modules/deaccession/actions/editAction.class.php
 (from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/actions/editDeaccessionAction.class.php)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/deaccession/actions/editAction.class.php
    Tue Jul 12 11:24:09 2011        (r9298, copy of r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/actions/editDeaccessionAction.class.php)
@@ -0,0 +1,168 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class AccessionEditDeaccessionAction extends DefaultEditAction
+{
+  // Arrays not allowed in class constants
+  public static
+    $NAMES = array(
+      'date',
+      'description',
+      'extent',
+      'identifier',
+      'reason',
+      'scope');
+
+  public function earlyExecute()
+  {
+    $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
+
+    $this->resource = new QubitDeaccession;
+
+    if (isset($this->getRoute()->resource))
+    {
+      $this->resource = $this->getRoute()->resource;
+
+      // Check user authorization
+      if (!QubitAcl::check($this->resource, 'update'))
+      {
+        QubitAcl::forwardUnauthorized();
+      }
+    }
+    else
+    {
+      $this->form->setDefault('accessionId', $this->request->accession);
+      $this->form->setValidator('accessionId', new sfValidatorInteger);
+      $this->form->setWidget('accessionId', new sfWidgetFormInputHidden);
+
+      $this->resource->accessionId = $this->request->accession;
+
+      // Check user authorization
+      if (!QubitAcl::check($this->resource, 'create'))
+      {
+        QubitAcl::forwardUnauthorized();
+      }
+    }
+
+    $title = $this->context->i18n->__('Add new deaccession record');
+    if (isset($this->getRoute()->resource))
+    {
+      if (1 > strlen($title = $this->resource->__toString()))
+      {
+        $title = $this->context->i18n->__('Untitled');
+      }
+
+      $title = $this->context->i18n->__('Edit %1%', array('%1%' => $title));
+    }
+
+    $this->response->setTitle("$title - {$this->response->getTitle()}");
+  }
+
+  protected function addField($name)
+  {
+    switch ($name)
+    {
+      case 'scope':
+        $this->form->setDefault('scope', 
$this->context->routing->generate(null, array($this->resource->scope, 'module' 
=> 'term')));
+        $this->form->setValidator('scope', new sfValidatorString);
+
+        $choices = array();
+        $choices[null] = null;
+        foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::DEACCESSION_SCOPE_ID) as $item)
+        {
+          $choices[$this->context->routing->generate(null, array($item, 
'module' => 'term'))] = $item;
+        }
+
+        $this->form->setWidget('scope', new sfWidgetFormSelect(array('choices' 
=> $choices)));
+
+        break;    
+
+      case 'description':
+      case 'extent':
+      case 'reason':
+        $this->form->setDefault($name, $this->resource[$name]);
+        $this->form->setValidator($name, new sfValidatorString);
+        $this->form->setWidget($name, new sfWidgetFormTextarea);
+
+        break;
+
+      case 'date':
+        // If it is a *new* deaccession, set current date as default
+        if (!isset($this->resource->id))
+        {
+          $dt = new DateTime;
+          $this->form->setDefault('date', $dt->format('Y-m-d'));
+          $this->form->setValidator('date', new sfValidatorString);
+          $this->form->setWidget('date', new sfWidgetFormInput);
+
+          break;
+        }
+
+      case 'identifier':
+        $this->form->setDefault($name, $this->resource[$name]);
+        $this->form->setValidator($name, new sfValidatorString);
+        $this->form->setWidget($name, new sfWidgetFormInput);
+
+        break;
+
+      default:
+
+        return parent::addField($name);
+    }
+  }
+
+  protected function processField($field)
+  {
+    switch ($field->getName())
+    {
+      case 'scope':
+        unset($this->resource->scope);
+
+        $value = $this->form->getValue('scope');
+        if (isset($value))
+        {
+          $params = $this->context->routing->parse(Qubit::pathInfo($value));
+          $this->resource->scope = $params['_sf_route']->resource;
+        }
+
+        break;
+
+      default:
+        return parent::processField($field);
+    }
+  }
+
+  public function execute($request)
+  {
+    parent::execute($request);
+
+    if ($request->isMethod('post'))
+    {
+      $this->form->bind($request->getPostParameters());
+      if ($this->form->isValid())
+      {
+        $this->processForm();
+
+        $this->resource->save();
+
+        $this->redirect(array($this->resource->accession, 'module' => 
'accession'));
+      }
+    }
+  }
+}

Copied: 
trunk/plugins/qtAccessionPlugin/modules/deaccession/actions/indexAction.class.php
 (from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/actions/indexDeaccessionAction.class.php)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/deaccession/actions/indexAction.class.php
   Tue Jul 12 11:24:09 2011        (r9298, copy of r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/actions/indexDeaccessionAction.class.php)
@@ -0,0 +1,74 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class AccessionIndexDeaccessionAction extends sfAction
+{
+  public function execute($request)
+  {
+    $this->resource = $this->getRoute()->resource;
+
+    // Check user authorization
+    if (!QubitAcl::check($this->resource, 'read'))
+    {
+      QubitAcl::forwardToSecureAction();
+    }
+
+    if (1 > strlen($title = $this->resource->__toString()))
+    {
+      $title = $this->context->i18n->__('Untitled');
+    }
+
+    $this->response->setTitle("$title - {$this->response->getTitle()}");
+
+    if (QubitAcl::check($this->resource, 'update'))
+    {
+      $validatorSchema = new sfValidatorSchema;
+      $values = array();
+
+      $validatorSchema->identifier = new sfValidatorString(array(
+        'required' => true), array(
+        'required' => $this->context->i18n->__('Identifier - This is a 
mandatory element.')));
+      $values['identifier'] = $this->resource->identifier;
+
+      $validatorSchema->date = new sfValidatorString(array(
+        'required' => true), array(
+        'required' => $this->context->i18n->__('Date of acquisition - This is 
a mandatory element.')));
+      $values['date'] = $this->resource->date;
+
+      $validatorSchema->scope = new sfValidatorString(array(
+        'required' => true), array(
+        'required' => $this->context->i18n->__('Scope - This is a mandatory 
element.')));
+      $values['identifier'] = $this->resource->scope;
+
+      $validatorSchema->description = new sfValidatorString(array(
+        'required' => true), array(
+        'required' => $this->context->i18n->__('Description - This is a 
mandatory element.')));
+      $values['identifier'] = 
$this->resource->getDescription(array('culltureFallback' => true));
+
+      try
+      {
+        $validatorSchema->clean($values);
+      }
+      catch (sfValidatorErrorSchema $e)
+      {
+        $this->errorSchema = $e;
+      }
+    }
+  }
+}

Copied: 
trunk/plugins/qtAccessionPlugin/modules/deaccession/templates/deleteSuccess.php 
(from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/templates/deleteDeaccessionSuccess.php)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/deaccession/templates/deleteSuccess.php 
    Tue Jul 12 11:24:09 2011        (r9298, copy of r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/templates/deleteDeaccessionSuccess.php)
@@ -0,0 +1,18 @@
+<h1><?php echo __('Are you sure you want to delete %1%?', array('%1%' => 
render_title($resource))) ?></h1>
+
+<?php echo $form->renderFormTag(url_for(array($resource, 'module' => 
'deaccession', 'action' => 'delete')), array('method' => 'delete')) ?>
+
+  <div class="actions section">
+
+    <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
+
+    <div class="content">
+      <ul class="clearfix links">
+        <li><?php echo link_to(__('Cancel'), array($resource, 'module' => 
'deaccession')) ?></li>
+        <li><input class="form-submit" type="submit" value="<?php echo 
__('Confirm') ?>"/></li>
+      </ul>
+    </div>
+
+  </div>
+
+</form>

Copied: 
trunk/plugins/qtAccessionPlugin/modules/deaccession/templates/editSuccess.php 
(from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/templates/editDeaccessionSuccess.php)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/deaccession/templates/editSuccess.php   
    Tue Jul 12 11:24:09 2011        (r9298, copy of r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/templates/editDeaccessionSuccess.php)
@@ -0,0 +1,52 @@
+<h1><?php echo __('Edit deaccession record') ?></h1>
+
+<h1 class="label"><?php echo render_title($resource) ?></h1>
+
+<?php echo $form->renderGlobalErrors() ?>
+
+<?php if (isset($sf_request->getAttribute('sf_route')->resource)): ?>
+  <?php echo $form->renderFormTag(url_for(array($resource, 'module' => 
'deaccession', 'action' => 'edit')), array('id' => 'editForm')) ?>
+<?php else: ?>
+  <?php echo $form->renderFormTag(url_for(array('module' => 'deaccession', 
'action' => 'add')), array('id' => 'editForm')) ?>
+<?php endif; ?>
+
+  <?php echo $form->renderHiddenFields() ?>
+
+  <?php echo $form->identifier
+    ->label(__('Deaccession number').' <span class="form-required" 
title="'.__('This is a mandatory element.').'">*</span>')
+    ->renderRow() ?>
+
+  <?php echo $form->scope
+    ->label(__('Scope').' <span class="form-required" title="'.__('This is a 
mandatory element.').'">*</span>')
+    ->renderRow() ?>
+
+  <?php echo $form->date
+    ->label(__('Date').' <span class="form-required" title="'.__('This is a 
mandatory element.').'">*</span>')
+    ->renderRow(array('class' => 'date-widget', 'icon' => 
image_path('calendar.png'))) ?>
+
+  <?php echo render_field($form->description
+    ->label(__('Description').' <span class="form-required" title="'.__('This 
is a mandatory element.').'">*</span>'), $resource, array('class' => 
'resizable')) ?>
+
+  <?php echo render_field($form->extent, $resource, array('class' => 
'resizable')) ?>
+
+  <?php echo render_field($form->reason, $resource, array('class' => 
'resizable')) ?>
+
+  <div class="actions section">
+
+    <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
+
+    <div class="content">
+      <ul class="clearfix links">
+
+        <?php if (isset($resource->id)): ?>
+          <li><?php echo link_to(__('Cancel'), array($resource, 'module' => 
'deaccession')) ?></li>
+          <li><input class="form-submit" type="submit" value="<?php echo 
__('Save') ?>"/></li>
+        <?php else: ?>
+          <li><?php echo link_to(__('Cancel'), array($resource->accession, 
'module' => 'accession')) ?></li>
+          <li><input class="form-submit" type="submit" value="<?php echo 
__('Create') ?>"/></li>
+        <?php endif; ?>
+
+      </ul>
+    </div>
+
+  </div>

Copied: 
trunk/plugins/qtAccessionPlugin/modules/deaccession/templates/indexSuccess.php 
(from r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/templates/indexDeaccessionSuccess.php)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/deaccession/templates/indexSuccess.php  
    Tue Jul 12 11:24:09 2011        (r9298, copy of r9297, 
trunk/plugins/qtAccessionPlugin/modules/accession/templates/indexDeaccessionSuccess.php)
@@ -0,0 +1,52 @@
+<h1><?php echo __('View deaccession record') ?></h1>
+
+<?php echo link_to_if(QubitAcl::check($resource, 'update'), '<h1 
class="label">'.render_title($resource).'</h1>', array($resource, 'module' => 
'deaccession', 'action' => 'edit'), array('title' => __('Edit accession 
record'))) ?>
+
+<?php if (isset($errorSchema)): ?>
+  <div class="messages error">
+    <ul>
+      <?php foreach ($errorSchema as $error): ?>
+        <li><?php echo $error ?></li>
+      <?php endforeach; ?>
+    </ul>
+  </div>
+<?php endif; ?>
+
+<div class="field">
+  <h3>Accession record</h3>
+  <div class="value">
+    <?php echo link_to($resource->accession->__toString(), 
array($resource->accession, 'module' => 'accession')) ?>
+  </div>
+</div>
+
+<?php echo render_show(__('Deaccession number'), 
render_value($resource->identifier)) ?>
+
+<?php echo render_show(__('Scope'), render_value($resource->scope)) ?>
+
+<?php echo render_show(__('Date'), render_value($resource->date)) ?>
+
+<?php echo render_show(__('Description'), 
render_value($resource->description)) ?>
+
+<?php echo render_show(__('Extent'), render_value($resource->extent)) ?>
+
+<?php echo render_show(__('Reason'), render_value($resource->reason)) ?>
+
+<div class="actions section">
+
+  <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
+
+  <div class="content">
+    <ul class="clearfix links">
+
+      <?php if (QubitAcl::check($resource, 'update') || 
(QubitAcl::check($resource, 'translate'))): ?>
+        <li><?php echo link_to(__('Edit'), array($resource, 'module' => 
'deaccession', 'action' => 'edit')) ?></li>
+      <?php endif; ?>
+
+      <?php if (QubitAcl::check($resource, 'delete')): ?>
+        <li><?php echo link_to(__('Delete'), array($resource, 'module' => 
'deaccession', 'action' => 'delete')) ?></li>
+      <?php endif; ?>
+
+    </ul>
+  </div>
+
+</div>

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to