[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-31 Thread Asad Rashid
The more simplest way is to set UNIQUE to the column of the database you want it to stay unique. That way a duplicate record will not be inserted and the insert query will return an error stating "record already exist". Check how to set your required column(s) "unique". This way is the fastest

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-23 Thread mostwanted
Thank you Villas, you've been much helpful On Thursday, July 23, 2020 at 2:05:49 PM UTC+2, villas wrote: > > As you've discovered, random doesn't work in this context. Make an array > of class attendee numbers and then allocate the class which has the fewest > students. > > > On Thursday, 23

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-23 Thread villas
As you've discovered, random doesn't work in this context. Make an array of class attendee numbers and then allocate the class which has the fewest students. On Thursday, 23 July 2020 12:50:00 UTC+1, mostwanted wrote: > > Well the whole concept behind this application was that allocation of

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-23 Thread mostwanted
Well the whole concept behind this application was that allocation of spaces in time, days & class rooms should be automatic, the user should just select the lecturer, the subject & the period the subject takes (Double session=2hrs, Single session=1hr) from there after the user submits that inf

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-23 Thread villas
Suggestion: Your idea of overriding the user's selections with random choices seems strange. Why not ask the user to specify a date and then show him which classes are available nearest that date/time? He can then choose one of those. On Wednesday, 22 July 2020 19:04:27 UTC+1, mostwanted wrot

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-22 Thread mostwanted
After a form has failed to save because that information already exists in the database I wanna try & alter the value that determines a day where the info is saved in the db for the form to be saved in a different day that does not contain similar form details currently attempting to be saved an

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-21 Thread Dave S
On Tuesday, July 21, 2020 at 3:16:29 AM UTC-7, villas wrote: > > Your my_validator function iterates through the whole table. This is OK > when you have a few records, but very inefficient if you have > thousands/millions. Why not simply query the table? Something like this... > > def my_va

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-21 Thread mostwanted
Impressive outlook Villas, thank you. On Tuesday, July 21, 2020 at 12:16:29 PM UTC+2, villas wrote: > > Your my_validator function iterates through the whole table. This is OK > when you have a few records, but very inefficient if you have > thousands/millions. Why not simply query the table?

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-21 Thread villas
Your my_validator function iterates through the whole table. This is OK when you have a few records, but very inefficient if you have thousands/millions. Why not simply query the table? Something like this... def my_validator(form): if db((db.lecture.id == form.vars.id) & (db.lecture.lec

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-19 Thread mostwanted
Thank you On Saturday, July 18, 2020 at 10:16:09 PM UTC+2, Dave S wrote: > > > > On Friday, July 17, 2020 at 2:38:43 AM UTC-7, mostwanted wrote: >> >> Hey Dave, thanks for replying, >> This below is what I tried & it seems to be working, idont know if the >> best solution but please help e where

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-18 Thread Dave S
On Friday, July 17, 2020 at 2:38:43 AM UTC-7, mostwanted wrote: > > Hey Dave, thanks for replying, > This below is what I tried & it seems to be working, idont know if the > best solution but please help e where u think I could improve it: > > def my_validator(form): > details=db(db.lecture)

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-17 Thread mostwanted
Hey Dave, thanks for replying, This below is what I tried & it seems to be working, idont know if the best solution but please help e where u think I could improve it: def my_validator(form): details=db(db.lecture).select() for d in details: if form.vars.lecturer==d.lecturer.id an

[web2py] Re: How to prevent submitting form details that already exist as a record in the database

2020-07-16 Thread Dave S
On Thursday, July 16, 2020 at 7:56:47 AM UTC-7, mostwanted wrote: > > I have created a calendar that assigns lesson_times & class_rooms > randomly. So far it has been working properly until a conflic arose, one > lecturer being assigned 2 classes at the same time, another one one > class_room