Split from #1545618: Various state issues
Allow states to be associated on a per registration-type basis.
Implementation would likely involve inventing bundles for registration_state entities, where bundle names are bundles of registration_type. Removing the default_state field from registration_state, and moving it to a new column of registration_type would also be required.
An observation, if this was to be implemented the state system would begin to resemble the field system (fields, instances etc). I still have the opinion that commandeering a field attached to registration types may serve better. If implemented using fields, restricting roles who can modify state would use something like field_permissions.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 1547190-states_per_registration-25.patch | 53.58 KB | shawn dearmond |
| #24 | 1547190-states_per_registration-24.patch | 52.68 KB | shawn dearmond |
| #21 | states-as-fields-1547190-21.patch | 54.21 KB | dpi |
| #17 | states-as-fields-1547190-17.patch | 54.43 KB | dpi |
| #16 | states-as-fields-1547190-16.patch | 54.32 KB | dpi |
Comments
Comment #1
dpiAs an in production use case of using fields instead of a the state system:
I have two fields on registration types, which would also be served well by this state system:
attending (set by registration owner): can set whether the user will be attending.
attended (set by entity owner): can set if the registration was used, ie: whether a user 'attended' the entity.
Comment #2
levelos commentedI think we would just need to add a registration_type col to the states schema, and default state would have to be unique across rows with the same registration type.
Re: fields, it's great to explore, but I'm still skeptical. E.g., how would we handle designating which states should be "active" and with that approach?
Comment #3
dpiI dont think we should throw away the entirety of the existing state code, much of the UI would be changed and made optional. However if an administrator decides to add state to a registration type, then they get bonus functionality.
I'll arrange some proof of concept code in the near future.
Comment #4
dpiWell, here's my shot at doing states as fields.
Lots of notes regarding the attached patch.
Schema
Forms
Fields
## Builtin States
Misc
Additional Questions
None of this has tests (yet). And there are some very minor things that need to be cleaned up.
Patch is diffed from c6eaa1ecbbb3706eb7c7e929d88d9ca4c8870081.
Whether or not this is actually implemented, I think the state system needs more cleanup before it is ready for prime time.
It would be great to get some feedback on any of this.
Comment #5
dpiWho doesn't love pictures?
Comment #6
levelos commented@dpi, thanks for your work on exploring this solution. I couldn't apply the patch cleanly, and received loads of errors after cleaning it up to apply enough to update, including calling non-existent functions and like. Taking it further, I was able to create a state, but there was no default state field applied to registration bundles. After I added one, I had two state fields appearing on the form.
Mind taking another pass at it so we can get a clear sense of what you're proposing?
Comment #7
dpiPerhaps check out the above commit and apply the patch on a new Drupal install as it will mess with your schema.
I'll work on rerolling against HEAD in the meantime.
Comment #8
dpiThis patch is against HEAD, ee749ff67bd8509cc80dcdbbcb8450912be9d824.
Like I said, schema changes. Recommend a new install since there's no upgrade path included.
Comment #9
levelos commented@dpi, thanks this applied, although there are lots of spacing issues with the patch. Not saying that to be obstinate / anal (;), just much harder to review the patch.
I also don't see a state field being added when a new registration type is being created.
Comment #10
dpiRight, the state field instance is not automatically created, I thought this would be by design. It wouldnt be hard to do this programmatically. The code will operate regardless of whether there are any states on a registration type.
Its not complete. Needs to be checked for coding style, add tests etc. Specifically, what do you mean by spacing issues?
Comment #11
levelos commentedIndentation changed (incorrectly) in every modified file. E.g.,
Comment #12
dpiWow. weird. IDE bug of the day.
Comment #13
dpiI apologise.
Comment #14
levelos commentedThanks @dpi, applied clean and some great ideas in there. I see the benefits of the hybrid field approach, but still not sure. Below are some issues and thoughts.
Comment #15
dpiCan all be solved by settings the state field type property 'no_ui' to true. Creating a field on install, and automatically attaching instances of this field to bundles.
A constant for the one canonical state field name would be created for this.
It just loads every state into memory, leaving conditionals to be done in code. The static caching for conditionals was very quirky, I've never seen such code before. If there is conditionals, then do it uncached? Creating new EFQ's arn't that hard ;)
Arguably, its unlikely there will be an excessively large state table.
registration_states doesnt have to be in entity.inc. Although I believe it makes sense since its an entity utility function.
You're right.
It was for the admin section, but I realised I didnt need it. Scrap it.
Thats fine, but per #4. A definition of 'active' needs to be exposed in the UI.
I figured adding an element in broadcast would be covered by a different issue. I removed the state business from registration_send_broadcast() because it was relevant.
Comment #16
dpiChanges since last patch. Taking into account IRC discussion.
Patch is inclusive of previous patches.
Comment #17
dpiMerged with 7.x-1.x
Added schema upgrade path.
And various other minor issues I have found.
Comment #18
jerdavisThis sounds very promising, particularly with some of the broadcast changes you mention in the last update. What's the state (no pun intended) of review on this? I'll probably be testing this patch early next week as this will potentially cover some needs for a client of ours.
Thanks!
Jeremiah
Comment #19
jerdavisHi DPI,
I'm not having a lot of luck applying this patch. The patch doesn't apply to 7.x-1.x HEAD (of course). I was able to apply it with warnings to a checkout of 7.x-1.x from commit d720a0a4d29debb941831d77637d6de903f58f92 (May 14th from Brandon).
I then attempted to enable Registration on a clean Drupal install.
When attempting to enable Registration I get:
FieldException: Attempt to create a field of unknown type <em class="placeholder">registration_state</em>. in field_create_field() (line 110 of /www/managed/managed/drupal/releases/drupal-7/gose/drupal/modules/field/field.crud.inc).This leaves me unable to create registration states or registration types. Creating a registration type results in:
ieldException: Attempt to create an instance of a field registration_state that doesn't exist or is currently inactive. in field_create_instance() (line 457 of /www/managed/managed/drupal/releases/drupal-7/gose/drupal/modules/field/field.crud.inc).I'm really interested in seeing this move forward personally, your description above makes this sounds like a great direction for State handling in the module. I'd be interested to hear more from the maintainers about the direction and future of this. It'll probably be a bit of work by DPI or anyone else to bring this up to date with other changes that have been committed so it might be nice to hear more about the acceptance of the suggested changes?
Thanks for your work DPI, I'm really hoping this moves forward!
Jeremiah
Comment #20
dpi@jerdavis Thanks
As you suspected, the patch relies on an older HEAD. If you would like to experiment with it, it is best to install Drupal and Registration new and checkout directly from my Git sandbox:
Branch 'states-as-fields-new' from http://drupal.org/sandbox/danph/1423784
I will bring this patch up to speed if there is still interest from @levelos et all.
Comment #21
dpiReroll (also pushed to sandbox)
Comment #22
shawn dearmond commentedPatch needs to be rerolled. It fails to apply.
Comment #23
socialnicheguru commentedi could not get it to apply cleanly to test either
Comment #24
shawn dearmond commentedOkay, I **MANUALLY** applied this patch to 7.x-1.x. It is now re-rolled, and the attached patch should now apply.
However, as I feared/expected, it still needs considerable work. For instance, when I enable the module now, I get:
And tests can't be run. It gives a similar error.
Comment #25
shawn dearmond commentedMy bad. I forgot a chunk of the code.
Attached is a better patch that not only applies, but actually works... mostly.
I'll keep this as "needs work" because 13 tests now fail. Also, tests should probably be written for the new functionality.
Comment #26
jerdavisChecking in on this. More flexible registration would be a great thing to have, and while the new wait list functionality gets part way towards what we're looking for, it's not quite there. The project this is related to isn't completely ready to go - so we've been waiting and hoping these tools would mature more. At some point in the near future we'll probably be getting rolling though, and I'll need to decide how best to move forward.
That may include working on this patch, but I'd only want to invest that kind of time here if there's a high likelyhood of the work being accepted. All that to say, what are the maintainers feelings on this approach? I took Shawn's work on it in September as a positive sign, but hit hasn't been touched since and things like the waitlist and http://drupal.org/node/1871570 have been developed around this, rather than finishing this work first (likely making the implementation of this state handling rewrite more complex).
Just looking for some input here so I can judge how best to proceed when the time comes.
Thanks!
Jeremiah
Comment #27
levelos commented@jerdavis, this is not hight our list nor have we heard much of outcry for adding this feature. I'm more inclined towards the states per type change than using fields for states at this point. So a patch addressing the former w/o the latter would certainly get serious considerations. Thanks for getting involved!
Comment #28
igorik commentedI am a big fan of this work, thinking that could be useful to have registration states for reach registration type, not same for every registration types on whole site.
Hope it will be working soon and it could be integrated into Registration core module.
Thanks for your work, guys
Comment #28.0
igorik commentedfield per
Comment #29
rattusrattus commentedIf anyone is looking to have a default state per registration type, check out #2055145: Allow different default statuses for different registration types
Comment #30
caxy4 commentedAs @ratface mentions - #2055145: Allow different default statuses for different registration types has been resolved, provides the ability to set a default state per registration type (if none is set, the global default registration state will be used), and will be available in the upcoming 7.x-1.4 release.
Comment #31
igorik commentedthis sounds good! Looking forward to new release! :)
Comment #32
john.oltman commentedThis is supported by the 3.x version of the module. Each registration type can have a different workflow.