← Back to team overview

amm-dev-tem team mailing list archive

[Branch ~amm-dev-tem/amm/trunk] Rev 24: A picture of a person can be submitted trough the edit formular

 

------------------------------------------------------------
revno: 24
committer: The Whole Life To Learn <thewholelifetolearn@xxxxxxxxx>
branch nick: sources
timestamp: Mon 2011-05-30 17:15:31 +0200
message:
  A picture of a person can be submitted trough the edit formular
removed:
  app/views/people/add_picture.ctp
modified:
  app/controllers/people_controller.php
  app/models/person.php
  app/views/people/add.ctp
  app/views/people/edit.ctp


--
lp:amm
https://code.launchpad.net/~amm-dev-tem/amm/trunk

Your team AMM dev team is subscribed to branch lp:amm.
To unsubscribe from this branch go to https://code.launchpad.net/~amm-dev-tem/amm/trunk/+edit-subscription
=== modified file 'app/controllers/people_controller.php'
--- app/controllers/people_controller.php	2011-05-27 05:44:03 +0000
+++ app/controllers/people_controller.php	2011-05-30 15:15:31 +0000
@@ -2,7 +2,7 @@
 class PeopleController extends AppController {
 
 	var $name = 'People';
-	var $helpers = array('Ajax', 'Javascript');
+	var $helpers = array('Js');
 
 	function index() {
 		$this->Person->recursive = 0;
@@ -68,24 +68,6 @@
 		$this->redirect(array('action' => 'index'));
 	}
 
-	function add_picture($id = null) {
-		if (!$id && empty($this->data)) {
-			$this->Session->setFlash(__('Invalid person', true));
-			$this->redirect(array('action' => 'index'));
-		}
-		if (!empty($this->data)) {
-			if ($this->Person->save($this->data)) {
-				$this->Session->setFlash(__('The picture has been saved', true));
-				$this->redirect(array('action' => 'index'));
-			} else {
-				$this->Session->setFlash(__('The picture could not be saved. Please, try again.', true));
-			}
-		}
-		if (empty($this->data)) {
-			$this->data = $this->Person->read(null, $id);
-		}
-	}
-
 	function admin_index() {
 		$this->Person->recursive = 0;
 		$this->set('people', $this->paginate());

=== modified file 'app/models/person.php'
--- app/models/person.php	2011-05-26 19:00:04 +0000
+++ app/models/person.php	2011-05-30 15:15:31 +0000
@@ -210,7 +210,7 @@
 	);
 	var $actsAs = array(
 		'Uploader.Attachment' => array(
-			'file' => array(
+			'picture' => array(
 				'uploadDir' => '/uploads/people/',	// Where to upload to, relative to app webroot
 				'dbColumn' => 'photo',	// The database column name to save the path to
 				'transforms' 	=> array(	// What transformations to do on images: scale, resize, etc

=== modified file 'app/views/people/add.ctp'
--- app/views/people/add.ctp	2011-05-26 19:00:04 +0000
+++ app/views/people/add.ctp	2011-05-30 15:15:31 +0000
@@ -63,7 +63,7 @@
 			)
 		);
 		echo $this->Form->input('job', array('label' => __('Job', true)));
-		echo $this->Form->input('file', array(
+		echo $this->Form->input('picture', array(
 			'label' => __('Photo', true),
 			'type' => 'file',
 			'error' => array(

=== removed file 'app/views/people/add_picture.ctp'
--- app/views/people/add_picture.ctp	2011-05-27 05:44:03 +0000
+++ app/views/people/add_picture.ctp	1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
-<div class="people form">
-<?php echo $this->Form->create('Person', array('type' => 'file'));?>
-	<fieldset>
-		<legend><?php echo __('Add a picture for ', true).$this->Form->value('Person.name'); ?></legend>
-	<?php
-		echo $this->Form->input('id');
-		echo $this->Form->input('file', array(
-			'label' => __('Photo', true),
-			'type' => 'file',
-			'error' => array(
-				'file' => __('The file you have submitted is not a picture (.jpg, .jpeg, .gif and .png files only are accepted)', true)
-				)
-			)
-		);
-	?>
-	</fieldset>
-<?php echo $this->Form->end(__('Submit', true));?>
-</div>
-<div class="actions">
-	<h3><?php __('Actions'); ?></h3>
-	<ul>
-
-		<li><?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $this->Form->value('Person.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $this->Form->value('Person.id'))); ?></li>
-		<li><?php echo $this->Html->link(__('List People', true), array('action' => 'index'));?></li>
-		<li><?php echo $this->Html->link(__('List Members', true), array('controller' => 'members', 'action' => 'index')); ?> </li>
-		<li><?php echo $this->Html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add')); ?> </li>
-		<li><?php echo $this->Html->link(__('List Person Infos', true), array('controller' => 'person_infos', 'action' => 'index')); ?> </li>
-		<li><?php echo $this->Html->link(__('New Person Info', true), array('controller' => 'person_infos', 'action' => 'add')); ?> </li>
-		<li><?php echo $this->Html->link(__('List Events', true), array('controller' => 'events', 'action' => 'index')); ?> </li>
-		<li><?php echo $this->Html->link(__('New Event', true), array('controller' => 'events', 'action' => 'add')); ?> </li>
-		<li><?php echo $this->Html->link(__('List Places', true), array('controller' => 'places', 'action' => 'index')); ?> </li>
-		<li><?php echo $this->Html->link(__('New Place', true), array('controller' => 'places', 'action' => 'add')); ?> </li>
-	</ul>
-</div>
\ No newline at end of file

=== modified file 'app/views/people/edit.ctp'
--- app/views/people/edit.ctp	2011-05-27 05:44:03 +0000
+++ app/views/people/edit.ctp	2011-05-30 15:15:31 +0000
@@ -1,3 +1,12 @@
+<?php
+echo $this->Html->script('jquery-1.6.x.min');
+
+$this->Js->get('#PersonEditForm')->event('submit',
+	"if($('#PersonPicture').val() == '') {
+		$('#PersonPicture').parent('div').detach();
+	}
+	return true;", true);
+;?>
 <div class="people form">
 <?php echo $this->Form->create('Person', array('type' => 'file'));?>
 	<fieldset>
@@ -64,14 +73,14 @@
 			)
 		);
 		echo $this->Form->input('job', array('label' => __('Job', true)));
-//		echo $this->Form->input('file', array(
-//			'label' => __('Photo', true),
-//			'type' => 'file',
-//			'error' => array(
-//				'file' => __('The file you have submitted is not a picture (.jpg, .jpeg, .gif and .png files only are accepted)', true)
-//				)
-//			)
-//		);
+		echo $this->Form->input('picture', array(
+			'label' => __('Photo', true),
+			'type' => 'file',
+			'error' => array(
+				'file' => __('The file you have submitted is not a picture (.jpg, .jpeg, .gif and .png files only are accepted)', true)
+				)
+			)
+		);
 		echo $this->Form->input('notes', array('label' => __('Notes/comments', true)));
 	?>
 	</fieldset>
@@ -92,4 +101,5 @@
 		<li><?php echo $this->Html->link(__('List Places', true), array('controller' => 'places', 'action' => 'index')); ?> </li>
 		<li><?php echo $this->Html->link(__('New Place', true), array('controller' => 'places', 'action' => 'add')); ?> </li>
 	</ul>
-</div>
\ No newline at end of file
+</div>
+<?php echo $this->Js->writeBuffer(); ?>
\ No newline at end of file