Re: [TurboGears] Displayed value on Multi-Select widget

2019-02-01 Thread Ádám Bozsányi
?

Daniel Latzer  ezt írta (időpont: 2019. jan. 31., Cs,
13:11):

> I finally got around to looking at this issue again and yes: that did the
> trick. Thanks a lot!
>
> On Wednesday, August 22, 2018 at 8:22:36 PM UTC+2, Alessandro Molina wrote:
>>
>> I think that what you are looking for is ``Deferred``:
>>
>>  event_date = CheckBoxList(id="event_date",
>> options=twf.Deferred(event_date_options))
>>
>> Should do the trick.
>>
>> There is a related discussion at
>> https://stackoverflow.com/questions/51161971/how-to-create-edit-forms-in-turbogear/51174896#51174896
>>
>> On Tue, Aug 21, 2018 at 3:36 PM Daniel Latzer 
>> wrote:
>>
>>> Nope, sorry. I resorted to scheduling a reboot for every night, since
>>> it's not that critical for the data to appear immediately in my case. It's
>>> not pretty, but it was the easiest solution at that point.
>>>
>>> On Tue, Aug 21, 2018 at 3:21 PM Marek Domiter 
>>> wrote:
>>>
 Hi Daniel,

 were you able to find solution to this? I'm trying to do the same
 thing, but no success.


 On Wednesday, 30 May 2018 10:26:47 UTC+2, Daniel Latzer wrote:

> Ah, nice, that link was exactly what i was looking for, thank you.
> Also the next section about custom dropdown data, since I want the
> EventDates to be filtered so that only dates can be selected that aren't 
> in
> the past. However this led me to a new problem:
>
> I've made my own field like shown at the bottom and added it, but
> _my_update_params seems to never be called. (It just displays like a
> PropertyMultipleSelectField would do, and ignores my filters. However if i
> change the superclass of EventDateField to PropertySingleSelectField, it
> gets displayed as a dropdown, so it isn't completely ignored. I've also
> attached the debugger to check, _my_update_params, or update_params for
> that matter doesn't appear to be called at all.
>
> (Also i'd like to use CheckBoxLIst instead, but it complained about me
> not providing options, and if that's not easy to do it's okay, i'll just
> stay with the MultipleSelect. I've also already tried this - doing
> `event_date = CheckBoxList(id="event_date", 
> options=event_date_options())`,
> but there i had the problem that it evaluated event_date_options() only
> once on starting the server, and i want the data options to be refreshed 
> on
> each load of the form)
>
> #class EventDateField(CheckBoxList)
> class EventDateField(PropertyMultipleSelectField):
>
> field_type="checkbox"
> def _my_update_params(self, d, nullable=False):
> dates = DBSession.query(OrderDate).filter(...).all()
> options = [(date.id, format_date(date.date)) for date in dates]
> d['options']=options
> return d
>
> class ActivityAddForm(AddRecordForm):
> __model__ = Activity
>
> event_date = EventDateField
>
>
> On Tue, May 29, 2018 at 1:36 PM Alessandro Molina <
> [email protected]> wrote:
>
 I think that usage of sprox/tgext.crud/tgext.admin have a lot of space
>> for improvements on documentation in TurboGears, so if you think there 
>> are
>> ways that the documentation can be improved once you got a clear
>> understanding on how you can do what you are trying to do feel free to
>> contribute any change you think might be required. I'll gladly review and
>> merge it.
>>
>> On Tue, May 29, 2018 at 1:33 PM Alessandro Molina <
>> [email protected]> wrote:
>>
> I think
>>> https://turbogears.readthedocs.io/en/latest/cookbook/sprox.html#custom-dropdown-field-names
>>> is what you are looking for (option was recently renamed to
>>> possible_field_names but works the same way)
>>> You can set it in __form_options__ for the admin
>>> crudControllerConfig and have the generated forms use that as their 
>>> preview
>>> field in single selects.
>>>
>>> For users and groups it works automatically because sprox tries to
>>> be smart in detecting the proper field to use and one of the heuristics 
>>> is
>>> to grab a field that is named "something_name" so group_name gets 
>>> picked.
>>>
>>> On Thu, May 24, 2018 at 3:06 PM Daniel Latzer 
>>> wrote:
>>>
>> Hello

 I've created two tables in an m:n relationship:

 Activity (id, name)
 EventDates (id, date)

 and linked these two using a sqlalchemy `relation`, mapping
 EventDates as `event_dates` to Activity.

 I want to create Activities that can take on one or more EventDates.
 Using the admin (and also a form generated with a
 `CrudRestController` as seen here
 ),
 the generated 

Re: [TurboGears] Displayed value on Multi-Select widget

2019-01-31 Thread Daniel Latzer
I finally got around to looking at this issue again and yes: that did the 
trick. Thanks a lot!

On Wednesday, August 22, 2018 at 8:22:36 PM UTC+2, Alessandro Molina wrote:
>
> I think that what you are looking for is ``Deferred``:
>
>  event_date = CheckBoxList(id="event_date", 
> options=twf.Deferred(event_date_options))
>
> Should do the trick.
>
> There is a related discussion at 
> https://stackoverflow.com/questions/51161971/how-to-create-edit-forms-in-turbogear/51174896#51174896
>
> On Tue, Aug 21, 2018 at 3:36 PM Daniel Latzer  > wrote:
>
>> Nope, sorry. I resorted to scheduling a reboot for every night, since 
>> it's not that critical for the data to appear immediately in my case. It's 
>> not pretty, but it was the easiest solution at that point.
>>
>> On Tue, Aug 21, 2018 at 3:21 PM Marek Domiter > > wrote:
>>
>>> Hi Daniel,
>>>
>>> were you able to find solution to this? I'm trying to do the same thing, 
>>> but no success.
>>>
>>>
>>> On Wednesday, 30 May 2018 10:26:47 UTC+2, Daniel Latzer wrote:
>>>
 Ah, nice, that link was exactly what i was looking for, thank you. Also 
 the next section about custom dropdown data, since I want the EventDates 
 to 
 be filtered so that only dates can be selected that aren't in the past. 
 However this led me to a new problem:

 I've made my own field like shown at the bottom and added it, but 
 _my_update_params seems to never be called. (It just displays like a 
 PropertyMultipleSelectField would do, and ignores my filters. However if i 
 change the superclass of EventDateField to PropertySingleSelectField, it 
 gets displayed as a dropdown, so it isn't completely ignored. I've also 
 attached the debugger to check, _my_update_params, or update_params for 
 that matter doesn't appear to be called at all.

 (Also i'd like to use CheckBoxLIst instead, but it complained about me 
 not providing options, and if that's not easy to do it's okay, i'll just 
 stay with the MultipleSelect. I've also already tried this - doing 
 `event_date = CheckBoxList(id="event_date", 
 options=event_date_options())`, 
 but there i had the problem that it evaluated event_date_options() only 
 once on starting the server, and i want the data options to be refreshed 
 on 
 each load of the form)

 #class EventDateField(CheckBoxList)
 class EventDateField(PropertyMultipleSelectField):

 field_type="checkbox"
 def _my_update_params(self, d, nullable=False):
 dates = DBSession.query(OrderDate).filter(...).all()
 options = [(date.id, format_date(date.date)) for date in dates]
 d['options']=options
 return d

 class ActivityAddForm(AddRecordForm):
 __model__ = Activity

 event_date = EventDateField


 On Tue, May 29, 2018 at 1:36 PM Alessandro Molina <
 [email protected]> wrote:

>>> I think that usage of sprox/tgext.crud/tgext.admin have a lot of space 
> for improvements on documentation in TurboGears, so if you think there 
> are 
> ways that the documentation can be improved once you got a clear 
> understanding on how you can do what you are trying to do feel free to 
> contribute any change you think might be required. I'll gladly review and 
> merge it.
>
> On Tue, May 29, 2018 at 1:33 PM Alessandro Molina <
> [email protected]> wrote:
>
 I think 
>> https://turbogears.readthedocs.io/en/latest/cookbook/sprox.html#custom-dropdown-field-names
>>  
>> is what you are looking for (option was recently renamed to 
>> possible_field_names but works the same way)
>> You can set it in __form_options__ for the admin crudControllerConfig 
>> and have the generated forms use that as their preview field in single 
>> selects.
>>
>> For users and groups it works automatically because sprox tries to be 
>> smart in detecting the proper field to use and one of the heuristics is 
>> to 
>> grab a field that is named "something_name" so group_name gets picked.
>>
>> On Thu, May 24, 2018 at 3:06 PM Daniel Latzer  
>> wrote:
>>
> Hello
>>>
>>> I've created two tables in an m:n relationship: 
>>>
>>> Activity (id, name)
>>> EventDates (id, date)
>>>
>>> and linked these two using a sqlalchemy `relation`, mapping 
>>> EventDates as `event_dates` to Activity.
>>>
>>> I want to create Activities that can take on one or more EventDates.
>>> Using the admin (and also a form generated with a 
>>> `CrudRestController` as seen here 
>>> ),
>>>  
>>> the generated Multi-Select widget in the new-Activity Form just 
>>> displays me 
>>> the primary key of the EventDate entries. I'd rather have it display 

Re: [TurboGears] Displayed value on Multi-Select widget

2018-08-22 Thread Alessandro Molina
I think that what you are looking for is ``Deferred``:

 event_date = CheckBoxList(id="event_date",
options=twf.Deferred(event_date_options))

Should do the trick.

There is a related discussion at
https://stackoverflow.com/questions/51161971/how-to-create-edit-forms-in-turbogear/51174896#51174896

On Tue, Aug 21, 2018 at 3:36 PM Daniel Latzer 
wrote:

> Nope, sorry. I resorted to scheduling a reboot for every night, since it's
> not that critical for the data to appear immediately in my case. It's not
> pretty, but it was the easiest solution at that point.
>
> On Tue, Aug 21, 2018 at 3:21 PM Marek Domiter 
> wrote:
>
>> Hi Daniel,
>>
>> were you able to find solution to this? I'm trying to do the same thing,
>> but no success.
>>
>>
>> On Wednesday, 30 May 2018 10:26:47 UTC+2, Daniel Latzer wrote:
>>
>>> Ah, nice, that link was exactly what i was looking for, thank you. Also
>>> the next section about custom dropdown data, since I want the EventDates to
>>> be filtered so that only dates can be selected that aren't in the past.
>>> However this led me to a new problem:
>>>
>>> I've made my own field like shown at the bottom and added it, but
>>> _my_update_params seems to never be called. (It just displays like a
>>> PropertyMultipleSelectField would do, and ignores my filters. However if i
>>> change the superclass of EventDateField to PropertySingleSelectField, it
>>> gets displayed as a dropdown, so it isn't completely ignored. I've also
>>> attached the debugger to check, _my_update_params, or update_params for
>>> that matter doesn't appear to be called at all.
>>>
>>> (Also i'd like to use CheckBoxLIst instead, but it complained about me
>>> not providing options, and if that's not easy to do it's okay, i'll just
>>> stay with the MultipleSelect. I've also already tried this - doing
>>> `event_date = CheckBoxList(id="event_date", options=event_date_options())`,
>>> but there i had the problem that it evaluated event_date_options() only
>>> once on starting the server, and i want the data options to be refreshed on
>>> each load of the form)
>>>
>>> #class EventDateField(CheckBoxList)
>>> class EventDateField(PropertyMultipleSelectField):
>>>
>>> field_type="checkbox"
>>> def _my_update_params(self, d, nullable=False):
>>> dates = DBSession.query(OrderDate).filter(...).all()
>>> options = [(date.id, format_date(date.date)) for date in dates]
>>> d['options']=options
>>> return d
>>>
>>> class ActivityAddForm(AddRecordForm):
>>> __model__ = Activity
>>>
>>> event_date = EventDateField
>>>
>>>
>>> On Tue, May 29, 2018 at 1:36 PM Alessandro Molina 
>>> wrote:
>>>
>> I think that usage of sprox/tgext.crud/tgext.admin have a lot of space
 for improvements on documentation in TurboGears, so if you think there are
 ways that the documentation can be improved once you got a clear
 understanding on how you can do what you are trying to do feel free to
 contribute any change you think might be required. I'll gladly review and
 merge it.

 On Tue, May 29, 2018 at 1:33 PM Alessandro Molina <
 [email protected]> wrote:

>>> I think
> https://turbogears.readthedocs.io/en/latest/cookbook/sprox.html#custom-dropdown-field-names
> is what you are looking for (option was recently renamed to
> possible_field_names but works the same way)
> You can set it in __form_options__ for the admin crudControllerConfig
> and have the generated forms use that as their preview field in single
> selects.
>
> For users and groups it works automatically because sprox tries to be
> smart in detecting the proper field to use and one of the heuristics is to
> grab a field that is named "something_name" so group_name gets picked.
>
> On Thu, May 24, 2018 at 3:06 PM Daniel Latzer 
> wrote:
>
 Hello
>>
>> I've created two tables in an m:n relationship:
>>
>> Activity (id, name)
>> EventDates (id, date)
>>
>> and linked these two using a sqlalchemy `relation`, mapping
>> EventDates as `event_dates` to Activity.
>>
>> I want to create Activities that can take on one or more EventDates.
>> Using the admin (and also a form generated with a
>> `CrudRestController` as seen here
>> ),
>> the generated Multi-Select widget in the new-Activity Form just displays 
>> me
>> the primary key of the EventDate entries. I'd rather have it display the
>> date of the EventDate entries.
>>
>> I've inherited this application and am not really familiar with
>> Turbogears. Looking at some already existing models that are tied in with
>> `TGAuthMetadata` i can see in the Admin that there is basically the same
>> thing going on with User <-> Group <-> Permissions, and in these forms 
>> the
>> user_name, group_name or 

Re: [TurboGears] Displayed value on Multi-Select widget

2018-08-21 Thread Daniel Latzer
Nope, sorry. I resorted to scheduling a reboot for every night, since it's
not that critical for the data to appear immediately in my case. It's not
pretty, but it was the easiest solution at that point.

On Tue, Aug 21, 2018 at 3:21 PM Marek Domiter 
wrote:

> Hi Daniel,
>
> were you able to find solution to this? I'm trying to do the same thing,
> but no success.
>
>
> On Wednesday, 30 May 2018 10:26:47 UTC+2, Daniel Latzer wrote:
>
>> Ah, nice, that link was exactly what i was looking for, thank you. Also
>> the next section about custom dropdown data, since I want the EventDates to
>> be filtered so that only dates can be selected that aren't in the past.
>> However this led me to a new problem:
>>
>> I've made my own field like shown at the bottom and added it, but
>> _my_update_params seems to never be called. (It just displays like a
>> PropertyMultipleSelectField would do, and ignores my filters. However if i
>> change the superclass of EventDateField to PropertySingleSelectField, it
>> gets displayed as a dropdown, so it isn't completely ignored. I've also
>> attached the debugger to check, _my_update_params, or update_params for
>> that matter doesn't appear to be called at all.
>>
>> (Also i'd like to use CheckBoxLIst instead, but it complained about me
>> not providing options, and if that's not easy to do it's okay, i'll just
>> stay with the MultipleSelect. I've also already tried this - doing
>> `event_date = CheckBoxList(id="event_date", options=event_date_options())`,
>> but there i had the problem that it evaluated event_date_options() only
>> once on starting the server, and i want the data options to be refreshed on
>> each load of the form)
>>
>> #class EventDateField(CheckBoxList)
>> class EventDateField(PropertyMultipleSelectField):
>>
>> field_type="checkbox"
>> def _my_update_params(self, d, nullable=False):
>> dates = DBSession.query(OrderDate).filter(...).all()
>> options = [(date.id, format_date(date.date)) for date in dates]
>> d['options']=options
>> return d
>>
>> class ActivityAddForm(AddRecordForm):
>> __model__ = Activity
>>
>> event_date = EventDateField
>>
>>
>> On Tue, May 29, 2018 at 1:36 PM Alessandro Molina 
>> wrote:
>>
> I think that usage of sprox/tgext.crud/tgext.admin have a lot of space for
>>> improvements on documentation in TurboGears, so if you think there are ways
>>> that the documentation can be improved once you got a clear understanding
>>> on how you can do what you are trying to do feel free to contribute any
>>> change you think might be required. I'll gladly review and merge it.
>>>
>>> On Tue, May 29, 2018 at 1:33 PM Alessandro Molina 
>>> wrote:
>>>
>> I think
 https://turbogears.readthedocs.io/en/latest/cookbook/sprox.html#custom-dropdown-field-names
 is what you are looking for (option was recently renamed to
 possible_field_names but works the same way)
 You can set it in __form_options__ for the admin crudControllerConfig
 and have the generated forms use that as their preview field in single
 selects.

 For users and groups it works automatically because sprox tries to be
 smart in detecting the proper field to use and one of the heuristics is to
 grab a field that is named "something_name" so group_name gets picked.

 On Thu, May 24, 2018 at 3:06 PM Daniel Latzer  wrote:

>>> Hello
>
> I've created two tables in an m:n relationship:
>
> Activity (id, name)
> EventDates (id, date)
>
> and linked these two using a sqlalchemy `relation`, mapping EventDates
> as `event_dates` to Activity.
>
> I want to create Activities that can take on one or more EventDates.
> Using the admin (and also a form generated with a `CrudRestController`
> as seen here
> ),
> the generated Multi-Select widget in the new-Activity Form just displays 
> me
> the primary key of the EventDate entries. I'd rather have it display the
> date of the EventDate entries.
>
> I've inherited this application and am not really familiar with
> Turbogears. Looking at some already existing models that are tied in with
> `TGAuthMetadata` i can see in the Admin that there is basically the same
> thing going on with User <-> Group <-> Permissions, and in these forms the
> user_name, group_name or permission_name get displayed in the Multi-Select
> and I cannot figure out how that has been achieved.
>
> So basically if I have this:
>
> class ActivityAddForm(AddRecordForm):
>  __model__ = Activity
>  __omit_fields__ = ['id']
>  event_dates = ??? # this has an m:n relation to EventDate
>
>
> How do i get the resulting Multi-Select to render something different
> than the primary key of EventDate? Is it derived from the model? Is it
> configured somewhere?

Re: [TurboGears] Displayed value on Multi-Select widget

2018-08-21 Thread Marek Domiter
Hi Daniel,

were you able to find solution to this? I'm trying to do the same thing, 
but no success.

On Wednesday, 30 May 2018 10:26:47 UTC+2, Daniel Latzer wrote:
>
> Ah, nice, that link was exactly what i was looking for, thank you. Also 
> the next section about custom dropdown data, since I want the EventDates to 
> be filtered so that only dates can be selected that aren't in the past. 
> However this led me to a new problem:
>
> I've made my own field like shown at the bottom and added it, but 
> _my_update_params seems to never be called. (It just displays like a 
> PropertyMultipleSelectField would do, and ignores my filters. However if i 
> change the superclass of EventDateField to PropertySingleSelectField, it 
> gets displayed as a dropdown, so it isn't completely ignored. I've also 
> attached the debugger to check, _my_update_params, or update_params for 
> that matter doesn't appear to be called at all.
>
> (Also i'd like to use CheckBoxLIst instead, but it complained about me not 
> providing options, and if that's not easy to do it's okay, i'll just stay 
> with the MultipleSelect. I've also already tried this - doing `event_date = 
> CheckBoxList(id="event_date", options=event_date_options())`, but there i 
> had the problem that it evaluated event_date_options() only once on 
> starting the server, and i want the data options to be refreshed on each 
> load of the form)
>
> #class EventDateField(CheckBoxList)
> class EventDateField(PropertyMultipleSelectField):
>
> field_type="checkbox"
> def _my_update_params(self, d, nullable=False):
> dates = DBSession.query(OrderDate).filter(...).all()
> options = [(date.id, format_date(date.date)) for date in dates]
> d['options']=options
> return d
>
> class ActivityAddForm(AddRecordForm):
> __model__ = Activity
>
> event_date = EventDateField
>
>
> On Tue, May 29, 2018 at 1:36 PM Alessandro Molina  > wrote:
>
>> I think that usage of sprox/tgext.crud/tgext.admin have a lot of space 
>> for improvements on documentation in TurboGears, so if you think there are 
>> ways that the documentation can be improved once you got a clear 
>> understanding on how you can do what you are trying to do feel free to 
>> contribute any change you think might be required. I'll gladly review and 
>> merge it.
>>
>> On Tue, May 29, 2018 at 1:33 PM Alessandro Molina > > wrote:
>>
>>> I think 
>>> https://turbogears.readthedocs.io/en/latest/cookbook/sprox.html#custom-dropdown-field-names
>>>  
>>> is what you are looking for (option was recently renamed to 
>>> possible_field_names but works the same way)
>>> You can set it in __form_options__ for the admin crudControllerConfig 
>>> and have the generated forms use that as their preview field in single 
>>> selects.
>>>
>>> For users and groups it works automatically because sprox tries to be 
>>> smart in detecting the proper field to use and one of the heuristics is to 
>>> grab a field that is named "something_name" so group_name gets picked.
>>>
>>> On Thu, May 24, 2018 at 3:06 PM Daniel Latzer >> > wrote:
>>>
 Hello

 I've created two tables in an m:n relationship: 

 Activity (id, name)
 EventDates (id, date)

 and linked these two using a sqlalchemy `relation`, mapping EventDates 
 as `event_dates` to Activity.

 I want to create Activities that can take on one or more EventDates.
 Using the admin (and also a form generated with a `CrudRestController` 
 as seen here 
 ),
  
 the generated Multi-Select widget in the new-Activity Form just displays 
 me 
 the primary key of the EventDate entries. I'd rather have it display the 
 date of the EventDate entries. 

 I've inherited this application and am not really familiar with 
 Turbogears. Looking at some already existing models that are tied in with 
 `TGAuthMetadata` i can see in the Admin that there is basically the same 
 thing going on with User <-> Group <-> Permissions, and in these forms the 
 user_name, group_name or permission_name get displayed in the Multi-Select 
 and I cannot figure out how that has been achieved.

 So basically if I have this:

 class ActivityAddForm(AddRecordForm):
  __model__ = Activity
  __omit_fields__ = ['id']
  event_dates = ??? # this has an m:n relation to EventDate


 How do i get the resulting Multi-Select to render something different 
 than the primary key of EventDate? Is it derived from the model? Is it 
 configured somewhere?

 I've been messing around with `PropertyMultipleSelectField`, but could 
 not figure out how to properly configure it to pass it as `event_dates`.

 Thanks for your time.

 -- 
 You received this message because you are subscribed to the Google 
 Groups "TurboGears" 

Re: [TurboGears] Displayed value on Multi-Select widget

2018-05-30 Thread Daniel Latzer
Ah, nice, that link was exactly what i was looking for, thank you. Also the
next section about custom dropdown data, since I want the EventDates to be
filtered so that only dates can be selected that aren't in the past.
However this led me to a new problem:

I've made my own field like shown at the bottom and added it, but
_my_update_params seems to never be called. (It just displays like a
PropertyMultipleSelectField would do, and ignores my filters. However if i
change the superclass of EventDateField to PropertySingleSelectField, it
gets displayed as a dropdown, so it isn't completely ignored. I've also
attached the debugger to check, _my_update_params, or update_params for
that matter doesn't appear to be called at all.

(Also i'd like to use CheckBoxLIst instead, but it complained about me not
providing options, and if that's not easy to do it's okay, i'll just stay
with the MultipleSelect. I've also already tried this - doing `event_date =
CheckBoxList(id="event_date", options=event_date_options())`, but there i
had the problem that it evaluated event_date_options() only once on
starting the server, and i want the data options to be refreshed on each
load of the form)

#class EventDateField(CheckBoxList)
class EventDateField(PropertyMultipleSelectField):

field_type="checkbox"
def _my_update_params(self, d, nullable=False):
dates = DBSession.query(OrderDate).filter(...).all()
options = [(date.id, format_date(date.date)) for date in dates]
d['options']=options
return d

class ActivityAddForm(AddRecordForm):
__model__ = Activity

event_date = EventDateField


On Tue, May 29, 2018 at 1:36 PM Alessandro Molina <
[email protected]> wrote:

> I think that usage of sprox/tgext.crud/tgext.admin have a lot of space for
> improvements on documentation in TurboGears, so if you think there are ways
> that the documentation can be improved once you got a clear understanding
> on how you can do what you are trying to do feel free to contribute any
> change you think might be required. I'll gladly review and merge it.
>
> On Tue, May 29, 2018 at 1:33 PM Alessandro Molina <
> [email protected]> wrote:
>
>> I think
>> https://turbogears.readthedocs.io/en/latest/cookbook/sprox.html#custom-dropdown-field-names
>> is what you are looking for (option was recently renamed to
>> possible_field_names but works the same way)
>> You can set it in __form_options__ for the admin crudControllerConfig and
>> have the generated forms use that as their preview field in single selects.
>>
>> For users and groups it works automatically because sprox tries to be
>> smart in detecting the proper field to use and one of the heuristics is to
>> grab a field that is named "something_name" so group_name gets picked.
>>
>> On Thu, May 24, 2018 at 3:06 PM Daniel Latzer  wrote:
>>
>>> Hello
>>>
>>> I've created two tables in an m:n relationship:
>>>
>>> Activity (id, name)
>>> EventDates (id, date)
>>>
>>> and linked these two using a sqlalchemy `relation`, mapping EventDates
>>> as `event_dates` to Activity.
>>>
>>> I want to create Activities that can take on one or more EventDates.
>>> Using the admin (and also a form generated with a `CrudRestController`
>>> as seen here
>>> ),
>>> the generated Multi-Select widget in the new-Activity Form just displays me
>>> the primary key of the EventDate entries. I'd rather have it display the
>>> date of the EventDate entries.
>>>
>>> I've inherited this application and am not really familiar with
>>> Turbogears. Looking at some already existing models that are tied in with
>>> `TGAuthMetadata` i can see in the Admin that there is basically the same
>>> thing going on with User <-> Group <-> Permissions, and in these forms the
>>> user_name, group_name or permission_name get displayed in the Multi-Select
>>> and I cannot figure out how that has been achieved.
>>>
>>> So basically if I have this:
>>>
>>> class ActivityAddForm(AddRecordForm):
>>>  __model__ = Activity
>>>  __omit_fields__ = ['id']
>>>  event_dates = ??? # this has an m:n relation to EventDate
>>>
>>>
>>> How do i get the resulting Multi-Select to render something different
>>> than the primary key of EventDate? Is it derived from the model? Is it
>>> configured somewhere?
>>>
>>> I've been messing around with `PropertyMultipleSelectField`, but could
>>> not figure out how to properly configure it to pass it as `event_dates`.
>>>
>>> Thanks for your time.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "TurboGears" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/turbogears.
>>> For more options, visit 

Re: [TurboGears] Displayed value on Multi-Select widget

2018-05-29 Thread Alessandro Molina
I think that usage of sprox/tgext.crud/tgext.admin have a lot of space for
improvements on documentation in TurboGears, so if you think there are ways
that the documentation can be improved once you got a clear understanding
on how you can do what you are trying to do feel free to contribute any
change you think might be required. I'll gladly review and merge it.

On Tue, May 29, 2018 at 1:33 PM Alessandro Molina <
[email protected]> wrote:

> I think
> https://turbogears.readthedocs.io/en/latest/cookbook/sprox.html#custom-dropdown-field-names
> is what you are looking for (option was recently renamed to
> possible_field_names but works the same way)
> You can set it in __form_options__ for the admin crudControllerConfig and
> have the generated forms use that as their preview field in single selects.
>
> For users and groups it works automatically because sprox tries to be
> smart in detecting the proper field to use and one of the heuristics is to
> grab a field that is named "something_name" so group_name gets picked.
>
> On Thu, May 24, 2018 at 3:06 PM Daniel Latzer  wrote:
>
>> Hello
>>
>> I've created two tables in an m:n relationship:
>>
>> Activity (id, name)
>> EventDates (id, date)
>>
>> and linked these two using a sqlalchemy `relation`, mapping EventDates as
>> `event_dates` to Activity.
>>
>> I want to create Activities that can take on one or more EventDates.
>> Using the admin (and also a form generated with a `CrudRestController` as
>> seen here
>> ),
>> the generated Multi-Select widget in the new-Activity Form just displays me
>> the primary key of the EventDate entries. I'd rather have it display the
>> date of the EventDate entries.
>>
>> I've inherited this application and am not really familiar with
>> Turbogears. Looking at some already existing models that are tied in with
>> `TGAuthMetadata` i can see in the Admin that there is basically the same
>> thing going on with User <-> Group <-> Permissions, and in these forms the
>> user_name, group_name or permission_name get displayed in the Multi-Select
>> and I cannot figure out how that has been achieved.
>>
>> So basically if I have this:
>>
>> class ActivityAddForm(AddRecordForm):
>>  __model__ = Activity
>>  __omit_fields__ = ['id']
>>  event_dates = ??? # this has an m:n relation to EventDate
>>
>>
>> How do i get the resulting Multi-Select to render something different
>> than the primary key of EventDate? Is it derived from the model? Is it
>> configured somewhere?
>>
>> I've been messing around with `PropertyMultipleSelectField`, but could
>> not figure out how to properly configure it to pass it as `event_dates`.
>>
>> Thanks for your time.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "TurboGears" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/turbogears.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.


Re: [TurboGears] Displayed value on Multi-Select widget

2018-05-29 Thread Alessandro Molina
I think
https://turbogears.readthedocs.io/en/latest/cookbook/sprox.html#custom-dropdown-field-names
is what you are looking for (option was recently renamed to
possible_field_names but works the same way)
You can set it in __form_options__ for the admin crudControllerConfig and
have the generated forms use that as their preview field in single selects.

For users and groups it works automatically because sprox tries to be smart
in detecting the proper field to use and one of the heuristics is to grab a
field that is named "something_name" so group_name gets picked.

On Thu, May 24, 2018 at 3:06 PM Daniel Latzer  wrote:

> Hello
>
> I've created two tables in an m:n relationship:
>
> Activity (id, name)
> EventDates (id, date)
>
> and linked these two using a sqlalchemy `relation`, mapping EventDates as
> `event_dates` to Activity.
>
> I want to create Activities that can take on one or more EventDates.
> Using the admin (and also a form generated with a `CrudRestController` as
> seen here
> ),
> the generated Multi-Select widget in the new-Activity Form just displays me
> the primary key of the EventDate entries. I'd rather have it display the
> date of the EventDate entries.
>
> I've inherited this application and am not really familiar with
> Turbogears. Looking at some already existing models that are tied in with
> `TGAuthMetadata` i can see in the Admin that there is basically the same
> thing going on with User <-> Group <-> Permissions, and in these forms the
> user_name, group_name or permission_name get displayed in the Multi-Select
> and I cannot figure out how that has been achieved.
>
> So basically if I have this:
>
> class ActivityAddForm(AddRecordForm):
>  __model__ = Activity
>  __omit_fields__ = ['id']
>  event_dates = ??? # this has an m:n relation to EventDate
>
>
> How do i get the resulting Multi-Select to render something different than
> the primary key of EventDate? Is it derived from the model? Is it
> configured somewhere?
>
> I've been messing around with `PropertyMultipleSelectField`, but could not
> figure out how to properly configure it to pass it as `event_dates`.
>
> Thanks for your time.
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/turbogears.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.