So, what I have is not working like this! :(
Richard On Tue, Jul 24, 2012 at 9:24 AM, Alec Taylor <alec.tayl...@gmail.com> wrote: > Trying to create a simple button (form), showing "Join group" if user > isn't a member, and "Leave group" if user is a member. > > On Tue, Jul 24, 2012 at 11:14 PM, Richard Vézina < > ml.richard.vez...@gmail.com> wrote: > >> I am not exactly sure what you really want to achieve, but I did >> something like that where the user is allow to change from one group to an >> other base on preset of allowed groups. If you are interested I can show >> you the code. >> >> Richard >> >> >> On Tue, Jul 24, 2012 at 9:09 AM, Alec Taylor <alec.tayl...@gmail.com>wrote: >> >>> I'm trying to create a simple form which presents the user with a >>> functional "Join" button if they aren't a member, and a "Leave group" >>> button if they aren't. >>> >>> Unfortunately I seem to be overcomplicating this: >>> >>> @auth.requires_login()def group_membership(group_id): >>> is_member = False >>> try: >>> if auth.user.id in db(db.group_of_events.id == >>> group_id).select()[0].members: >>> is_member=True >>> except TypeError: >>> pass >>> >>> return dict(is_member=is_member) >>> >>> @auth.requires_login()def add_member_to_group(group_id): >>> success=False >>> try: >>> group = db(db.group_of_events.id == group_id).select()[0] >>> if auth.user.id not in group.members: >>> group.update_record( members=group.members+auth.user.id ) >>> success=True >>> except TypeError: >>> pass >>> >>> return dict(success=success) >>> >>> >>> Is there an easier way of creating a form with one option? >>> >>> Thanks for all suggestions, >>> >>> Alec Taylor >>> >>> -- >>> >>> >>> >>> >> >> -- >> >> >> >> > > -- > > > > --