Hi all,

This is my first post. I've been playing with web2py for few months now. 
After trying out number of other frameworks, I decided to build my app with 
web2py because of known reasons, it rocks :) 

Although, I have number of years of experience with html, css and to some 
extent php, this is my first project using python and jquery. Python side is 
working out fine but with jquery (AJAX) is causing me some grief.

My app requires availability calendar, I already used this solution 
http://www.ajaxavailabilitycalendar.com/ (built with mootools, php)  for 
other projects and it is closest open source solution which meets my 
requirements. here is demo:

ww.ajaxavailabilitycalendar.com/demo 

and admin demo:

http://www.ajaxavailabilitycalendar.com/calendar/ac-admin/.

To chance it and go with easy route, did anybody built something similar, or 
if not, would anybody be interested building this app/plugin for web2py? :)

I was searching trough previous posts and couldn't find examples which would 
help me. In one older post there was reference to booking.w2p but this app 
is no longer available on web2py.com site (I guess it was superseded by 
appointment app).

I will have to build something similar either way, but it will take me much 
longer, due to my newbie status, so if you have any suggestion or pointers 
how to start with this please let me know.

In brief these functionalities are required (model is below).

1. How to display jquery calendar (e.g pop up calendar) as inline calendar 
without visible  input form field (3 months or 12 months view). something 
like this http://jqueryui.com/demos/datepicker/#inline
2. When view is loaded, app should query db; table listing_item with id as 
criteria (sent through args[0]) and auth.user; display marked dates in 
in-line calendar (or other better method). I could probably build this 
function my self but again, integration with jquery is the problem for me)
3. how to use ajax to create/update database records with onclick events 
(multiple onclick on single date in calendar should change record in state 
field in booking table which is looping through all the field states in 
booking_states table)? non-existing db record, for particular date, will use 
create and existing record, for particular date, will use update (crud or 
SQLForm...)
4.  view one: with above features, so read/write for listing_item for 
auth.user
5. view two: displaying read only calendar populated with records from db 
(depending on listing_item.id)
6 generally every booking entry will be whole day event, (based on 
booking_state.class_name), 

If anybody could provide examples for first three points, it would help me 
alot.

Let say this is the model (might have mistakes - just a concept for now, 
database structure is inspired by above mentioned open source project)

db.define_table("booking_state",
    Field('name',type='string',length=64, label="Booking State"),
    Field('code',type='string',length=64, label="Booking Code"),    
    Field('active',type='boolean', label="Active",default=1),
    Field('class_name', type='string', length=30), 
    format="%(name)s")    
db.booking_state.name.requires = IS_NOT_IN_DB(db,"booking_state.name")    


booking state CSV
booking_state.id    booking_state.name    booking_state.code    
booking_state.active    booking_state.class_name    
1    Booked    b    1    booked    
2    Booked am    b_am    1    booked_am    
3    Booked pm    b_pm    1    booked_pm    
4    Provisional    pr    1    booked_pr    
5    Provisional am    pr_am    1    booked_pr_am    
6    Provisional pm    pr_pm    1    booked_pr_pm    
7    Change Over Day        1    changeover    
8    Special Offer        1    offer    


db.define_table("booking",
    Field('listing',db.listing_item, label="Listing ID"),    
    Field('state',db.booking_state),
    Field('sortable',type="integer", default),            
    Field('the_date',type='date', widget=date_widget, label="The Date"),  
##I was only playing with date widget, not required
    Field('posted_by',db.auth_user,writable=False))
       
db.booking.state.requires = IS_IN_DB(db,"booking_state.id","%(name)s")    
db.booking.posted_by.default = auth.user.id if auth.user else 0



db.define_table("listing_item",
    Field('title',length=128),
    Field('body',type='text'),
    Field('posted_on','datetime',writable=False),
    Field('posted_by',db.auth_user,writable=False),
    Field('client',default=request.client,writable=False,readable=False))

db.listing_item.title.requires = [IS_NOT_EMPTY(), 
IS_NOT_IN_DB(db,'listing_item.title')]
db.listing_item.posted_by.default = auth.user.id if auth.user else 0
db.listing_item.posted_by.writable = 
db.listing_item.posted_by.readable=False
db.listing_item.title.requires = IS_LENGTH(minsize=3, maxsize=128)
db.listing_item.body.requires = IS_LENGTH(minsize=10)



Thanks and regards,
Ivica

 
 

Reply via email to