Commit Graph
2898 Commits
Author SHA1 Message Date
Bharat Mediratta 9e9c5397b7 Qualify the Bad Request output when the name is missing 2010-01-17 16:59:25 -08:00
Bharat Mediratta 4197ee39b9 Catch ORM_Validation_Exception and turn it into a 400 Bad Request with
appropriate error output.
2010-01-17 16:58:54 -08:00
Bharat Mediratta afb3fa71b9 Get rid of internal_only designation -- it's too hard to enforce cleanly. 2010-01-17 16:58:47 -08:00
Bharat Mediratta fafa7f277f Remove a @todo. 2010-01-17 16:55:48 -08:00
Bharat Mediratta bb79a1455a Remove unnecessary comment. 2010-01-17 16:55:11 -08:00
Bharat Mediratta f70130b820 Special case output for ORM_Validation_Exceptions 2010-01-17 13:30:06 -08:00
Bharat Mediratta f0a290fc76 If we call original() and there's no $original yet, then consider this
to be the original.  That should be safe because we're already
guarding __set, __unset and save.
2010-01-17 13:29:36 -08:00
Bharat Mediratta cfb27dde02 Adjust installers to work with model based validation. 2010-01-17 13:28:24 -08:00
Bharat Mediratta 9488684220 Move model rules down into their validate() function for consistency.
Change "in_use" error to "conflict" for consistency.
2010-01-17 12:30:24 -08:00
Bharat Mediratta 3789b85b7d Move rules down into validate() and improve valid_author(). 2010-01-17 12:19:24 -08:00
Bharat Mediratta 4f8c98a7bc Move rules entirely down into validate() so that we can be more
sophisticated but keep all our rules in one place.

Add rules for most fields.
2010-01-17 12:13:25 -08:00
Bharat Mediratta 5c49c041e7 Use "(string) $form" instead of "$form->__toString()" 2010-01-16 22:42:02 -08:00
Bharat Mediratta 1c85cf6397 Convert comment code over to model based validation. 2010-01-16 22:27:07 -08:00
Bharat Mediratta 39ad9fa9a0 Get rid of add_rules_from() -- it's no longer necessary now that we're doing model based validation. 2010-01-16 21:25:17 -08:00
Bharat Mediratta 4a2d5bc9e2 Convert Users_Controller to model based validation. 2010-01-16 21:24:18 -08:00
Bharat Mediratta 6a4dda9bde Convert Admin_Users_Controller, User_Model and Group_Model to use
model based validation.
2010-01-16 21:15:12 -08:00
Bharat Mediratta a691dcc63c Convert Admin_Users::add_user() to use model based validation. Get
the rules and business logic out of the form and user::create(), and
move it into User_Model::save().
2010-01-16 19:58:55 -08:00
Bharat Mediratta fdcb4a1f32 PHPdoc. 2010-01-16 18:16:47 -08:00
Bharat Mediratta a5aacfa4a6 Don't forget to save when we make insignificant chagnes only. 2010-01-16 18:10:40 -08:00
Bharat Mediratta 7f20f66079 Whitespace. 2010-01-16 18:00:02 -08:00
Bharat Mediratta ff728b3ccd Whitespace. 2010-01-16 17:51:57 -08:00
Bharat Mediratta 8ce11ac970 Convert Movies_Controller::update() over to model based validation. 2010-01-16 12:07:36 -08:00
Bharat Mediratta efdb73cb98 Make movie creation use model based validation. Move movie related
logic from movie::create() into Item_Model
2010-01-16 12:00:50 -08:00
Bharat Mediratta b5a6a6a5d5 Oops, log::failure() doesn't exist. Use log::error(). 2010-01-16 11:44:21 -08:00
Bharat Mediratta 5a8449f16d Convert Photos_Controller::update() to use model based validation. 2010-01-16 11:12:27 -08:00
Bharat Mediratta 9f6dba7238 Check for illegal extensions in valid_name()
Fix a bug where we were not calling valid_data_file correctly.
2010-01-16 11:12:19 -08:00
Bharat Mediratta bf085a1a17 Convert photo uploading over to the new model based validation
approach.

- Rearrange Simple_Uploader_Controller::add_photo() to validate
  the form early in the process, and switch to using model based
  validation.

- Move thumbnail generation into gallery_event::item_created() so
  that it's decoupled from the model.

- Delete photo::create() and move all of its logic into
  Item_Model::save().

- Add Item_Model::$data_file to track the data file associated
  with new movies and photos.

- Do some cleanup on the validation callbacks -- it turns out the
  2nd argument is the field name not the value.
2010-01-16 00:51:31 -08:00
Bharat Mediratta d7eb102312 Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev 2010-01-16 00:19:47 -08:00
Bharat Mediratta 2c2c77ea39 Remove debug code. 2010-01-16 00:19:35 -08:00
Bharat Mediratta 434d351b2f Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
Conflicts:
	modules/gallery/models/item.php
2010-01-16 00:15:23 -08:00
Bharat Mediratta dcf4b5e71a Don't pass MY_ORM::original() to update event handlers, since after
parent::save() it'll be reset.  Clone it first.

This is an alternate fix for #978.
2010-01-16 00:13:28 -08:00
Bharat Mediratta 9f03d36d6e Don't use MY_ORM::original() here since the values may not have
changed since the last save.  Instead, use the original ORM passed in.
2010-01-16 00:10:55 -08:00
Bharat Mediratta 00c73a4b07 Revert "Fix for ticket #978. Don't reset the original property as part of the save processing, because that will overwrite the original values with all the new values. The problem with the original approach is that when changed event handlers used ->original(), it had already been reset as part of the save processing. Went back and forth on either leaving this alone and forcing callers to save the original prior to calling the save function, but there were a few event handlers that used ->original(). This seemed the easier change. So to reset the original you need to call reload() or clear(). There is now an optional parameter on the reload to only reload the original."
This reverts commit daeaca110d.
2010-01-15 23:53:43 -08:00
Bharat Mediratta 99073c3e20 Revert "Did the old commit then save trick"
This reverts commit e41ad23a8e.
2010-01-15 23:53:35 -08:00
Bharat Mediratta 654b103355 Validate the model type. 2010-01-15 13:41:46 -08:00
Bharat Mediratta 916da15cbb Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev 2010-01-15 13:36:16 -08:00
Bharat Mediratta 1066e64354 Call parent::save() before releasing the lock to make creating the hole and filling it an atomic operation. 2010-01-15 12:41:22 -08:00
Bharat Mediratta 50e3cc5837 Move model business logic out of album::create() and into
Item_Model::save().  This makes creating albums similar to editing
them and makes it difficult to create an album poorly.  I expect to be
able to remove a lot of code from the photo and movie helper because
it's duplicated here.

In order to do this, I refactored ORM_MPTT::add_to_parent() into
ORM_MPTT::save() so we now add it to the parent when we do save.  This
allows us to call save() only once which saves a database call per
add.

The Albums_Controller logic is roughly the same as before.

Haven't updated the tests yet, they're going to fail miserably since
many of them depend on album::create() which is now gone.
2010-01-15 12:15:20 -08:00
Bharat Mediratta 5809949ae8 Don't use Input directly to get album names, etc. Use the form fields. 2010-01-15 11:28:05 -08:00
Bharat Mediratta 94f58e8b65 Move setting Item_Model::rand_key into Item_Model::save() since it's
business logic.
2010-01-15 10:48:39 -08:00
Bharat Mediratta 1a557ce5a6 Use $value in valid_xxx() functions instead of the member field. They're equivalent, but it's more intuitive this way. 2010-01-15 10:36:56 -08:00
Bharat Mediratta b3e328c9ff Begin the process of converting to model based validation. Right
now only Albums_Controller::update() supports the pattern.  All
form and controller based validation happening when editing an
album has been moved over.

Model based validation means that our REST controllers share the
same validation as web controllers.  We'll have consistency
enforced at the model level, which is a Good Thing.

The basic pattern is now:
1) Rules are in the model

2) ORM::validate() (which is called by ORM::save() but you can
   call it directly, too) checks the model for all the rules and
   throws an ORM_Validation_Exception if there are failures

3) Actions are no longer taken when you call Item_Model::__set().
   Instead, they're all queued up and executed when you call
   Item_Model::save().

Notes:
- item::validate_xxx() functions are now in Item_Model::
- We still call $form->validate() because the form can have
 rules (and forms triggered by events will likely continue to
 have rules.
2010-01-14 21:04:09 -08:00
Tim Almdal 260660b2f6 Somemore K24 migration holdovers. need to specify the where statement with operands. '=' is no longer assumed. Fixes ticket #979 2010-01-13 12:08:56 -08:00
Tim Almdal e41ad23a8e Did the old commit then save trick 2010-01-13 11:47:27 -08:00
Tim Almdal daeaca110d Fix for ticket #978. Don't reset the original property as part of the save processing, because that will overwrite the original values with all the new values. The problem with the original approach is that when changed event handlers used ->original(), it had already been reset as part of the save processing. Went back and forth on either leaving this alone and forcing callers to save the original prior to calling the save function, but there were a few event handlers that used ->original(). This seemed the easier change. So to reset the original you need to call reload() or clear(). There is now an optional parameter on the reload to only reload the original. 2010-01-13 11:27:09 -08:00
Tim Almdal 639f1e741a Put quotes around the item titles in all the messages and more importantly actually display the original's title properly. Fixes ticket #966, but does now show us ticket #978 2010-01-12 11:42:31 -08:00
Tim Almdal e81acce985 If the user hits enter in the search text field, then cancel the submission, because the search is done in the browser and the the enter will unexpectedly reload the root directory. 2010-01-12 09:42:06 -08:00
Tim Almdal 42d7c9590e Correct the "l10n_client_data[index] is undefined" error. 2010-01-12 08:58:49 -08:00
Tim Almdal 9ff9d70fe2 Some whitespace and syntax corrects 2010-01-12 08:32:33 -08:00
Tim Almdal 3dfac5884f Add a css id attribute to the i10n-edit-translation element. Fixes ticket #969. 2010-01-12 08:31:28 -08:00