[web2py] multiple views same controller

2014-05-19 Thread ctrlSoft
Hi, what is the best  way to make multiple views for the same controller.
i have an application with multiple domains .com .de .it co.uk
for every domain the controllers, models is the same but in views i have to 
make some changes it's different for every domain
for static files i used routes, but for views is a little hard to handle 
this
i want to have smth like:
views/
de/default/
com/default/
it/default
or 

views/default/com/...
views/default/de/...
views/default/it/

is there a way execept response.view in every function?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] submit twice form to update in DB

2014-03-12 Thread ctrlSoft

I have a form,  so i have to submit twice to see changes in database, on 
first submit data is null

import json
 record = db(db.sf_contract.sf_login_id == auth.user.id).select().first() 
form_ccdata = 
json.dumps({"credit_card_type":request.vars.credit_card_type,"card_holder_name":request.vars.card_holder_name,"credit_card_number":request.vars.credit_card_number,"cvc2":request.vars.cvc2,"expiration_year":request.vars.expiration_year,"expiration_month":request.vars.expiration_month})
contract_form = SQLFORM(db.sf_contract, record, 
hidden=dict(ccdata=form_ccdata)) 
try:
ccdata = json.loads(record.ccdata)
except Exception, e: 
ccdata = 
json.loads('{"credit_card_type":"test","card_holder_name":"test","credit_card_number":"test","cvc2":"test","expiration_year":"test","expiration_month":"test"}')

input_credit_card_type = SELECT(_name='credit_card_type', 
_value=ccdata['credit_card_type'], _class='form-control input-sm') 
input_card_holder_name = 
INPUT(_name='card_holder_name',_type='text',_value=ccdata['card_holder_name'], 
_class='form-control input-sm') 
input_credit_card_number = INPUT(_name='credit_card_number', _type='text', 
_value=ccdata['credit_card_number'], _class='form-control input-sm') 
input_cvc2 = INPUT(_name='cvc2', type='text', _value=ccdata['cvc2'], 
_class='form-control input-sm') 
input_expiration_year = INPUT(_name='expiration_year',_type='text', 
_value=ccdata['expiration_year'], _class='form-control input-sm') 
input_expiration_month = INPUT(_name='expiration_month', _type='text', 
_value=ccdata['expiration_month'], _class='form-control input-sm') 

contract_form[0].insert(-1,[input_credit_card_type,input_card_holder_name, 
input_credit_card_number, input_cvc2, 
input_expiration_year,input_expiration_month])
 if contract_form.process().accepted: 
response.flash = show_alert('alert-success', 'Data saved')
elif contract_form.errors:
response.flash = show_alert('alert-warning', 'Form has errors')
 return dict(contract_form=contract_form) 


as i undersand on first instance when i visit url for this function 
request.vars should be null, because there is no form submision and the 
same on first submit, but on second submit data is saved.
how can i fix this to save on first submit?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] populate extra elements from one db field and table field

2014-03-12 Thread ctrlSoft
hi
db.define_table('sf_contract',
Field('id','id', readable=False),
Field('sf_login_id', readable=False, writable=False, requires=IS_IN_DB(db, 
db.sf_login.id)),
#.  
Field('ccdata')) # this field contains a json 

in ccdata  i have to store a json {"expiration_year": "2014", 
"credit_card_type": "visa", "cvc2": "***", "credit_card_number": 
"123456789", "expiration_month": "12", "card_holder_name": "user"}
so in my controller i added some extra elements where i populate them with 
data from json
import json
 record = db(db.sf_contract.sf_login_id == auth.user.id).select().first() 
contract_form = SQLFORM(db.sf_contract, record) 
#add extra elements to from, since data for credit card is stored as json
input_credit_card_type = SELECT(_name='credit_card_type') 
input_card_holder_name = INPUT(_name='card_holder_name', type='text') 
input_credit_card_number = INPUT(_name='credit_card_number') 
input_cvc2 = INPUT(_name='cvc2') 
input_expiration_year = INPUT(_name='expiration_year') 
input_expiration_month = INPUT(_name='expiration_month') 

contract_form[0].insert(-1,[input_credit_card_type,input_card_holder_name, 
input_credit_card_number, input_cvc2, 
input_expiration_year,input_expiration_month])
 #populate form with data from ccdata field 
try:
ccdata = json.loads(record.ccdata)
except Exception, e: 
ccdata = json.loads('{"credit_card_type":"","card_holder_name":"Alex from 
controller","credit_card_number":"12346","cvc2":"","expiration_year":"","expiration_month":""}')

contract_form.vars.credit_card_type = ccdata['credit_card_type']
contract_form.vars.card_holder_name = ccdata['card_holder_name']
contract_form.vars.credit_card_number = ccdata['credit_card_number']
contract_form.vars.cvc2 = ccdata['cvc2']
contract_form.vars.expiration_year = ccdata['expiration_year']
contract_form.vars.expiration_month = ccdata['expiration_month'] 

#save data to ccdata field on submit
ccdata = json.dumps({"credit_card_type":request.vars.credit_card_type,
 "card_holder_name":request.vars.card_holder_name,
 "credit_card_number":request.vars.card_holder_name,
 "cvc2":request.vars.cvc2,
 "expiration_year":request.vars.expiration_year,
 "expiration_month":request.vars.expiration_month})

contract_form.vars.ccdata = ccdata
if contract_form.process().accepted: 
response.flash = show_alert('alert-success', 'Data saved')
elif contract_form.errors:
response.flash = show_alert('alert-warning', 'Form has errors')


return dict(contract_form=contract_form) 

form is populating with data from db but  on submit i got  'Table' object 
has no attribute 'credit_card_type'
i need to populate extra elements from json and to save them

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] custom login_bare()

2013-05-28 Thread ctrlSoft
i want keep users in the same table (default auth), and i have 2 kind of 
auth. 1 basic and second is oauth.(facebook) 
in basic auth i use standart authentification, but with oauth i want to 
verify users by email, name .. token
once auth object password is required i decided for oauth do define a 
custom login_bare() where i will check what i need, and execute 
#auth.login_user(db.auth_user(oauth_user_id)) 

should i modify gluon/tools.py or import somewhere in modules and Create 
MyCustomAuth() with custom login_bare()?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: add items in navbar .. mode=dropdown

2013-04-30 Thread ctrlSoft
by default i have, login, logout  register, i wish i could append some 
links only if auth.user

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] add items in navbar .. mode=dropdown

2013-04-30 Thread ctrlSoft
hi, how to add items in 

...
...
...

generated by auth.navbar(mode="dropdown"),

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: pass db,tablename,fields ... values to module or define table in module?

2013-04-10 Thread ctrlSoft
thanks a lot for your sugetions and quick responses.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: pass db,tablename,fields ... values to module or define table in module?

2013-04-10 Thread ctrlSoft

in model dbtables.py
#.
#.
db.define_table('wishlist',
Field('user_id', db.auth_user, 
requires=IS_IN_DB(db,'auth_user.id','%(username)s')),
Field('offer_id', db.offer, requires=IS_IN_DB(db,'offer.id','%(title)s')),
Field('created_on', type='datetime', default=request.now, writable=False))
#.
#.

in modules wishlist.py  (this is just the ideea how i want to pass objects, 
i dont know how to do this correctly)

from gluon import*

class WishList():
def add_to_wish_list(self,db,table,field1,value1,field2,value2): # or is 
better list of **fields,**values ? 
try:
db.table.insert(field1=value1,field2=value2) #insert or validate_and_insert?
return 'Successfuly added to wishlist'
except:
return 'Error. Try again latter'

#remove_from_wish_list()
#get_user_wish_list()
#
# 


in one of the controllers default.py
#..
#..


@auth.requires_login()
def add_to_wishlist():
wishlist_obj = WishList()
status_wishlist_add = 
wishlist_obj.add_to_wish_list(db,wishlist,'user_id',auth.user_id,'offer_id',requested_offer_id)
return status_wishlist_add

#..
#..



-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] pass db,tablename,fields ... values to module or define table in module?

2013-04-10 Thread ctrlSoft
my db.tables are defined in model, i have 3 controllers, and i have some 
functions that are used in all 3, so i decided to create an module. now i'm 
a little confused, i saw some examples where tables are defined in module, 
and other posts where is talinkg about import
wich is the best way? 

i would prefer to maintain tables in model and pass 
(db,tablename,field1,value1..) to my class and so on.(if my 
preference is not SF, can help me with it?)


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: auth.settings.extra_fields

2013-04-05 Thread ctrlSoft
models are executed in alphabetical order. db.py and after that 
companies.py, you make reference to a non define table. you sould define 
companies table right after auth = Auth(db) and before auth.settings.
extra_fields['auth_user'] =
auth = Auth(db)
#
#
#
#
db.define_table('companies',
Field('name', 'string',
  required=True,
  requires=IS_NOT_EMPTY(),
  label=LABEL(T("Naziv"), _for="companies_name")),
Field('url_sufix', 'string',
  required=True,
  requires=IS_NOT_EMPTY(),
  unique=True,
  label=LABEL(T("Url-sufix"), _for="companies_url_sufix"
)),
Field('logo', 'upload',
  label=LABEL(T("Logo"), _for="companies_logo")),
Field('deleted', 'boolean'))


auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
default=False),
   Field('company_id', 'reference 
companies', requires=IS_IN_DB(db,db.companies.id))]


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: how to send bulk emails with web2py

2013-04-05 Thread ctrlSoft
Amazon Simple Email Service (Amazon SES)
http://aws.amazon.com/ses/

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: OAuth2/Facebook auth alongside standard authentication

2013-04-03 Thread ctrlSoft
din you successfully implemented this?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] guidelines to implement oauth with basic web2py auth (noob question)

2013-04-03 Thread ctrlSoft
i want in my application to implement 2 kind of auth(basic and oauth in my 
case facebook)
1)should i keep it separate? or to generate an entry in basic for every 
external first login
2)posibility to merge them latter
3)should i create a custom Auth() for external login?

i'm a little confused with this methods. wich is the best, simpler, easyer 
to implent.
i tried few examples found on here on groups but without succes. i need 
smth like web2pyslices.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: [solved] Re: Facebook conect and ExtendedLoginForm()

2013-04-01 Thread ctrlSoft
hi, i try to use web2social example, but got an error, 

{
   "error": {
  "message": "Invalid redirect_uri: Given URL is not allowed by the 
Application configuration.",
  "type": "OAuthException",
  "code": 191
   }
}



i setup, in facebook apps dashboard site url http://mysite.com/web2social, 
but redirect uri in browser is my ip..  http://  
&redirect_uri=http%3A%2F%2F178.168.82.176%2 
how to fix this?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] facebook connect

2013-03-26 Thread ctrlSoft
hi, i want to implement 2 kind of login on my app.
1) basic auth
2) facebook connect
i extended auth_user

auth.settings.extra_fields['auth_user']= [
  Field('ballance', type='double', default=0, writable=False, 
readable=False),
  Field('image', type='string'),
  Field('phone', type='integer'),
  Field('birthday', type='date')]


auth.define_tables(username=True, signature=False)

i want when user connect with facebook to insert in auth_user new record 
with facebook data (firstname, lastname, birthday, profile picture .) 
do you have a working example?
what is the best practice?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] strange error

2012-12-24 Thread ctrlSoft
 [Errno 1] _ssl.c:503: error:140943FC:SSL 
routines:SSL3_READ_BYTES:sslv3 alert bad record mac

-- 





[web2py] Re: authentification,registration fails

2012-08-12 Thread ctrlSoft
version is 1.99.7,  i have 10 websites (10 apps in applications/ folder) in 
4 from its, i periodicaly make chages, but i dont think that code from one 
application can affect all applications. in web2py code i didn't made any 
changes or upgrades. 

-- 





[web2py] authentification,registration fails

2012-08-12 Thread ctrlSoft
hi, my web2py app is hosted on webfaction. everything worked fine. about 3 
weeks ago authentification,registration stopped working. first in chrome 
not worked after a few days in firefox  
http://agsystem.md/welcome/default/user/register?_next=/welcome/default/index
 
does anybody has the same problem?

-- 





Re: [web2py] Re: prettydate question

2012-07-25 Thread ctrlSoft


On Wednesday, July 25, 2012 7:17:43 PM UTC+3, Alec Taylor wrote:
>
> On Tue, Jul 24, 2012 at 2:28 AM, ctrlSoft  wrote:
>
>>  yes.
>>>>
>>> http://i.imgur.com/jaeop.jpg
>>
>> http://i.imgur.com/xPBG1.jpg 
>>  
>> Quick aside, that view you've screenshotted, would you be able to show me 
> the code (view+controller) you used to generate it?
>

view (line 29):
https://github.com/dimadeveatii/licitatii/blob/master/views/achizitii_cop/grid_partial.html
 

controller:
https://github.com/dimadeveatii/licitatii/blob/master/controllers/achizitii_cop.py
 

-- 





Re: [web2py] prettydate question

2012-07-25 Thread ctrlSoft
browser is set up to english, but in model i do T.force('ro'). without 
forced translation result is the same

-- 



# coding: utf8
{
'!=': '!=',
'!langcode!': 'ro',
'!langname!': 'Rom?n?',
'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"update" (actualizeaz?) este o expresie op?ional? precum "c?mp1=\'valoare_nou?\'". Nu pute?i actualiza sau ?terge rezultatele unui JOIN',
'%(nrows)s records found': '%(nrows)s ?nregistr?ri g?site',
'%d hours ago': '%d hours ago',
'%d weeks ago': '%d saptamani in urma',
'%d-%m-%Y': '%d-%m-%Y',
'%d-%m-%Y %H:%M:%S': '%d-%m-%Y %H:%M:%S',
'%s %%{row} deleted': '%s linii ?terse',
'%s %%{row} updated': '%s linii actualizate',
'%s selected': '%s selectat(e)',
'%Y-%m-%d': '%Y-%m-%d',
'%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
'(something like "it-it")': '(ceva ce seam?n? cu "it-it")',
'1 month ago': '1 luna in urma',
'1 week ago': '1 saptamana in urma',
'<': '<',
'<=': '<=',
'=': '=',
'>': '>',
'>=': '>=',
'A new version of web2py is available': 'O nou? versiune de web2py este disponibil?',
'A new version of web2py is available: %s': 'O nou? versiune de web2py este disponibil?: %s',
'About': 'Despre',
'about': 'despre',
'About application': 'Despre aplica?ie',
'Access Control': 'Control acces',
'Add': 'Adaug?',
'additional code for your application': 'cod suplimentar pentru aplica?ia dvs.',
'admin disabled because no admin password': 'administrare dezactivat? deoarece parola de administrator nu a fost furnizat?',
'admin disabled because not supported on google app engine': 'administrare dezactivat? deoarece func?ionalitatea nu e suportat pe Google App Engine',
'admin disabled because unable to access password file': 'administrare dezactivat? deoarece nu exist? acces la fi?ierul cu parole',
'Admin is disabled because insecure channel': 'Adminstrarea este dezactivat? deoarece conexiunea nu este sigur?',
'Admin is disabled because unsecure channel': 'Administrarea este dezactivat? deoarece conexiunea nu este securizat?',
'Administration': 'Administrare',
'Administrative Interface': 'Interfa?? administrare',
'Administrator Password:': 'Parol? administrator:',
'Adresa': 'Adresa',
'Ai uitat parola?': 'Ai uitat parola?',
'Ajax Recipes': 'Re?ete Ajax',
'And': '?i',
'and rename it (required):': '?i renumi?i (obligatoriu):',
'and rename it:': ' ?i renumi?i:',
'appadmin': 'appadmin',
'appadmin is disabled because insecure channel': 'appadmin dezactivat deoarece conexiunea nu e sigur?',
'application "%s" uninstalled': 'aplica?ia "%s" a fost dezinstalat?',
'application compiled': 'aplica?ia a fost compilat?',
'application is compiled and cannot be designed': 'aplica?ia este compilat? ?i nu poate fi editat?',
'Are you sure you want to delete file "%s"?': 'Sigur ?terge?i fi?ierul "%s"?',
'Are you sure you want to delete this object?': 'Sigur ?terge?i acest obiect?',
'Are you sure you want to uninstall application "%s"': 'Sigur dezinstala?i aplica?ia "%s"',
'Are you sure you want to uninstall application "%s"?': 'Sigur dezinstala?i aplica?ia "%s"?',
'ATTENTION: Login requires a secure (HTTPS) connection or running on localhost.': 'ATEN?IE: Nu v? pute?i conecta dec?t utiliz?nd o conexiune securizat? (HTTPS) sau rul?nd aplica?ia pe computerul local.',
'ATTENTION: TESTING IS NOT THREAD SAFE SO DO NOT PERFORM MULTIPLE TESTS CONCURRENTLY.': 'ATEN?IE: Nu pute?i efectua mai multe teste o dat? deoarece lansarea ?n execu?ie a mai multor subpocese nu este sigur?.',
'ATTENTION: you cannot edit the running application!': 'ATEN?IE: nu pute?i edita o aplica?ie ?n curs de execu?ie!',
'Autentificare': 'Autentificare',
'Authentication': 'Autentificare',
'Autoritatea Contractanta': 'Autoritatea Contractanta',
'Available databases and tables': 'Baze de date ?i tabele disponibile',
'Back': '?napoi',
'Buy this book': 'Cump?r? aceast? carte',
'cache': 'cache',
'Cache Keys': 'Chei cache',
'cache, errors and sessions cleaned': 'cache, erori ?i sesiuni golite',
'Cannot be empty': 'Nu poate fi vid',
'Cannot compile: there are errors in your app.Debug it, correct errors and try again.': 'Compilare imposibil?: aplica?ia con?ine erori. Deboga?i aplica?ia ?i ?ncerca?i din nou.',
'cannot create file': 'fi?ier imposibil de creat',
'cannot upload file "%(filename)s"': 'imposibil de ?nc?rcat fi?ierul "%(filename)s"',
'Categoria': 'Categoria',
'Change Password': 'Schimbare parol?',
'Change password': 'Schimbare parol?',
'change password': 'schimbare parol?',
'check all': 'co?a?i tot',
'Check to delete': 'Co?a?i pentru a ?terge',
'clean': 'golire',
'Clear': 'Gole?te',
'click to check for upgrades': 'Clic pentru a verifica dac? exist? upgrade-uri',
'Client IP': 'IP client',
'Cod Banca': 'Cod Banca',
'Cod Fiscal': 'Cod Fiscal',
'Community': 'Comunitate',
'compile': 'compilare',
'compiled application removed': 'aplica?ia compilat? a fost ?tears?',
'Components and Plugins': 'Componente ?i plugin-uri',
'Cont de decontare': 'Cont de decontare',
'Cont Trezorerial'

Re: [web2py] prettydate question

2012-07-25 Thread ctrlSoft
but with translation wont work, i have al translation files in languages 
folder.

-- 





Re: [web2py] prettydate question

2012-07-25 Thread ctrlSoft


On Tuesday, July 24, 2012 5:58:16 PM UTC+3, dbdeveloper wrote:
>
>  ctrlSoft, is issue still present ?
>
> Vladyslav Kozlovskyy (Ukraine)
>
> 23.07.12 13:32, ctrlSoft написав(ла):
>  
> datetime format is: 2012-07-18 10:00:00  
>  
>  hi in view i have following code:
> {{=prettydate(row.deadline,T)}}
>
>  but result is :
> %d days ago 
>  %d days ago  
> %d days ago   
>  %d days ago   
>  ...
> 1 week ago
> 1 week ago
> ...
> %d weeks ago 
>  %d weeks ago 
>  %d weeks ago 
>  
>  how to display 
> 4 days ago
> 5 days ago
> ...
> 2 weeks ago
> 3 weeks ago
> ... 
> ...
>
>  -- 
>  
>  
> ( web2py version is from trunk.) i tried Bruno solution 
> {{=prettydate(row.deadline, lambda x: x)}}  and it works...
>
>  
 

-- 





[web2py] Re: prettydate question

2012-07-23 Thread ctrlSoft

>
> yes.
>>
> http://i.imgur.com/jaeop.jpg

http://i.imgur.com/xPBG1.jpg 

-- 





[web2py] prettydate question

2012-07-23 Thread ctrlSoft
datetime format is: 2012-07-18 10:00:00  

hi in view i have following code:
{{=prettydate(row.deadline,T)}}

but result is :
%d days ago 
%d days ago  
%d days ago   
%d days ago   
...
1 week ago
1 week ago
...
%d weeks ago 
%d weeks ago 
%d weeks ago 

how to display 
4 days ago
5 days ago
...
2 weeks ago
3 weeks ago
... 
...

-- 





[web2py] image thumb

2012-06-28 Thread ctrlSoft
hi i would like to implement in my app a feature , create thumbs runtime 
like in picasa or imgur
original image 
http://i.imgur.com/E9az6.jpg 
thumb croped
http://i.imgur.com/E9az6*b*.jpg  

or in picasa
original image:
https://lh3.googleusercontent.com/-iNUvq0K9l24/Tyr6IfaT76I/ArI/C_9RUy_o38A/s634/SecureData-logo-design.gif
 
thumb croped
https://lh3.googleusercontent.com/-iNUvq0K9l24/Tyr6IfaT76I/ArI/C_9RUy_o38A/
*s256-c*/SecureData-logo-design.gif
 
https://lh3.googleusercontent.com/-iNUvq0K9l24/Tyr6IfaT76I/ArI/C_9RUy_o38A/
*s128-c*/SecureData-logo-design.gif
 


i want to save just original image and retrieve when i need different size 
of thumbnail, what is the best way?  any sugestions?


[web2py] date/datetime format question

2012-06-23 Thread ctrlSoft
hi, my datetime field  format is
Field('deadline','datetime', requires=IS_DATETIME(format=('%d-%m-%Y 
%H:%M:%S')),  label=T('Deadline')),

 but in view  row.deadline is displayed in this format 2012-06-27 11:00:00  
and in exported csv the same. 
how do i set datetime format that is displayed in view.

-- 





Re: [web2py] count current visitors

2012-06-18 Thread ctrlSoft
with page views i understand. but without any analitycs tools, is there a 
method to count active/oline visitors not registered users. 
i want to display on my page:

total visits: 01234...
today:01234..
*online:5*



Re: [web2py] count current visitors

2012-06-18 Thread ctrlSoft
thanks, very helpfull


[web2py] count current visitors

2012-06-18 Thread ctrlSoft
hi, how to count current site visitors? smth like in google analitycs ... 
real-time visitors.

[web2py] Re: sqlform.grid html text

2012-06-03 Thread CtrlSoft
thanks! 

On Tuesday, May 29, 2012 1:14:54 AM UTC+3, villas wrote:
>
> You could try to use .represent.  I mean something a bit like this...
>
> db.yourtable.yourfield.represent = lambda yourfield,row: XML(yourfield)
> query = db
> grid = SQLFORM.grid(query.)
> return dict(grid=grid)
>
> Hope it works!
>


[web2py] Re: appadmin in Romanian (for Massimo)

2012-06-03 Thread CtrlSoft

salut Ioane! )

[web2py] sqlform.grid html text

2012-05-26 Thread CtrlSoft
hi, how to display in sqlform.grid -> viewhtml formated text?

i mean:  *someText lazy** fox*   instead ofsomeText lazy 
fox

[web2py] Re: pass table name in rows

2012-05-24 Thread CtrlSoft
added_on field is datetime, so i want to sort rows by date time
rows = rows.sort(lambda row: row.added_on) 

the main idea consist in showing last 10 added articles or news, ordered by 
added_on field

it can be 7 news or 3 articles
5 news 5 articles
1 news 9 artilces 




[web2py] pass table name in rows

2012-05-23 Thread CtrlSoft
hi, i have this controller:
def index():

rows1 = db(db.news.public == True).select(orderby=~db.news.added_on, 
limitby=(0,10))
rows2 = db(db.articles.public == 
True).select(orderby=~db.articles.added_on, limitby=(0,10))   
rows = rows1.as_list()+rows2.as_list() 
return dict(rows=rows)

the view:
in view i need to know table name to generate url

{{if rows:}}
{{for row in rows:}}
#if row.table_name == aritlces

{{=H4(A(row['title_'+lang], _href=URL('default', 'article', 
args=row['id'])))}}  

#else
 {{=H4(A(row['title_'+lang], _href=URL('default', 'news_content', 
args=row['id'])))}} 

 
{{pass}}
{{pass}}


article and news functions:
def article():
 return dict(row=db.articles[request.args(0)])

def news_content():
 return dict(row=db.news[request.args(0)])

any sugestions?



[web2py] orderby from 2 tables

2012-05-06 Thread CtrlSoft
hi, i have 2 tables both has "added_on"  field

i need last 'n'(lets assume n=5) rows from both tables ordered by added_on. 
it can be 1 from first table and 4 from second or 2|3

rows1 =db(db.table1).select(orderby=~db.table1.added_on, limitby=(0,5))
rows2 =db(db.table2).select(orderby=~db.table2.added_on, limitby=(0,5)) 

i need smth like this

 rows = rows1+rows2 
 rows->orderby(added_on)

 return dict(first 5 row in rows)

how to do this in a smarter way?




[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread CtrlSoft


On Saturday, May 5, 2012 2:40:52 PM UTC+3, kenji4569 wrote:
>
> I think so, but I don't have any clue for this session problem..
>
> 2012年5月5日土曜日 19時58分19秒 UTC+9 CtrlSoft:
>>
>> on localhost works fine beacause, it is using the same session, but on 
>> server, when i acces page app creates one session and when i submit the 
>> upload form it creates another one session, i think the problem is that 
>> there is different sessions. app remember previous session but form pass 
>> another session? it is right? 
>
>
this problem is only in Chrome, IE,Firefox,Opera everything works fine. 


[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread CtrlSoft
on localhost works fine beacause, it is using the same session, but on 
server, when i acces page app creates one session and when i submit the 
upload form it creates another one session, i think the problem is that 
there is different sessions. app remember previous session but form pass 
another session? it is right? 

[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread CtrlSoft
u can check above links, still not solved problem

[web2py] Re: plugin from dev.s-cubism.com question

2012-05-05 Thread CtrlSoft
this is my online version

> http://agsystem.md/upload/plugin_elrte_widget/index
>>  
>>
>
local host version can be accesed here:
 http://89.28.110.232:8100/upload/plugin_elrte_widget/index


is the same application


[web2py] plugin from dev.s-cubism.com question

2012-05-04 Thread CtrlSoft
hi i installed this plugin from dev.s-cubism.com
http://dev.s-cubism.com/plugin_elrte_widget 

i have a problem with upload/list uploaded files
on local host works fine, but when i upload it to server, upload is done, 
but the uploaded file is not listing/appear in dialog 
anybody  used it? to give me some suggetsions. thx in advance 



[web2py] update images computed field .. again

2012-05-01 Thread CtrlSoft
hi i have a resize function wich creates image thumbanils...
def THUMB(image, nx=120, ny=120):
from PIL import Image 
import os  
try:
img = Image.open(request.folder + 'static/img_folder/' + image)
img.thumbnail((nx,ny), Image.ANTIALIAS) 
root,ext = os.path.splitext(image)
thumb='%s_thumb%s' %(root, ext)
img.save(request.folder + 'static/img_folder/' + thumb)
return thumb
except: 
return None  
 
and this :
db.define_table("news",
Field('image', 'upload', requires=IS_EMPTY_OR(IS_IMAGE()), 
uploadfolder=request.folder+'static/img_folder', autodelete=True), 
Field('image_thumb', 'upload', compute=lambda r: 
THUMB(r['image']), uploadfolder=request.folder+'static/img_folder', 
autodelete=True), 
Field("title",label=T('Title'),requires=IS_NOT_EMPTY()),
Field("content" 
,type='text',label=T('Content'),requires=IS_NOT_EMPTY()))

on row edit  when i change row image or delete only image big image is 
deleted/replaced but image_thumb stil remains on disk , could you give me 
any suggestions?


Re: [web2py] autodelete image computed field

2012-04-29 Thread CtrlSoft
on row delete works, but on row edit  when i change row image or delete 
only image, image_thumb stil remains on disk

[web2py] autodelete image computed field

2012-04-28 Thread CtrlSoft

hi i have a resize function wich creates image thumbanils...
def THUMB(image, nx=120, ny=120):
from PIL import Image 
import os  
try:
img = Image.open(request.folder + 'static/img_folder/' + image)
img.thumbnail((nx,ny), Image.ANTIALIAS) 
root,ext = os.path.splitext(image)
thumb='%s_thumb%s' %(root, ext)
img.save(request.folder + 'static/img_folder/' + thumb)
return thumb
except: 
return None  
 
and this :
db.define_table("news",
Field('image', 'upload', requires=IS_EMPTY_OR(IS_IMAGE()), 
uploadfolder=request.folder+'static/img_folder', autodelete=True), 
Field('image_thumb', 'upload', compute=lambda r: THUMB(r['image']), 
autodelete=True), 
Field("title",label=T('Title'),requires=IS_NOT_EMPTY()),
Field("content" 
,type='text',label=T('Content'),requires=IS_NOT_EMPTY()))

the problem is when i delete a row, image("big image") is deleteing from 
disk but the image_thumb stil remains on disk. 
any solutions are welcome :), thx

___
Alex



Re: [web2py] response.view html file from static

2012-04-26 Thread CtrlSoft

>
> thanks.  works also on windows, 
>
  

 http://agsystem.md/  

On Thursday, April 26, 2012 11:32:45 PM UTC+3, rochacbruno wrote:
>
> if you are on linux, try:
>
> def myfunction():
>
> response.view = *'../*
> static/tinymce/jscripts/tiny_mce/plugins/files.html' 
>
> return dict()
>
>
> response.render uses /view as root folder, so you can navigate from there.
>
> On Thu, Apr 26, 2012 at 4:53 PM, CtrlSoft  wrote:
>
>> def myfunction():
>>
>> response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' 
>>
>> return dict()
>>
>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>  
On Thursday, April 26, 2012 11:32:45 PM UTC+3, rochacbruno wrote:
>
> if you are on linux, try:
>
> def myfunction():
>
> response.view = *'../*
> static/tinymce/jscripts/tiny_mce/plugins/files.html' 
>
> return dict()
>
>
> response.render uses /view as root folder, so you can navigate from there.
>
> On Thu, Apr 26, 2012 at 4:53 PM, CtrlSoft  wrote:
>
>> def myfunction():
>>
>> response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' 
>>
>> return dict()
>>
>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>  
On Thursday, April 26, 2012 11:32:45 PM UTC+3, rochacbruno wrote:
>
> if you are on linux, try:
>
> def myfunction():
>
> response.view = *'../*
> static/tinymce/jscripts/tiny_mce/plugins/files.html' 
>
> return dict()
>
>
> response.render uses /view as root folder, so you can navigate from there.
>
> On Thu, Apr 26, 2012 at 4:53 PM, CtrlSoft  wrote:
>
>> def myfunction():
>>
>> response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' 
>>
>> return dict()
>>
>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>  

[web2py] response.view html file from static

2012-04-26 Thread CtrlSoft
i have a file located under static folder that i want to return as view


i tried this:
def myfunction():

response.view = 'static/tinymce/jscripts/tiny_mce/plugins/files.html' 

return dict()

but doesnt workt
any ideas?



[web2py] Re: object is not callable

2012-04-24 Thread CtrlSoft

>
> i think the problem is in request.args so i tried smth like this:
>
  
arg = request.args[0]
rows = db(db.articles.reference == arg).select(*articles,limitby=(0,30))
return dict(row=db.menu[arg], rows = rows)
 
and still have problems but another error:

Traceback (most recent call last):
  File "/home/zerooo123/web2py/gluon/restricted.py", line 205, in restricted
exec ccode in environment
  File "/home/zerooo123/web2py/applications/orhei/controllers/default.py", line 
185, in 
  File "/home/zerooo123/web2py/gluon/globals.py", line 173, in 
self._caller = lambda f: f()
  File "/home/zerooo123/web2py/applications/orhei/controllers/default.py", line 
61, in menu
arg = request.args[0]
TypeError: 'NoneType' object is not subscriptable



the code where a generate link is:

 "+str(b['title_'+lang])+""+tree_side(tree,b.id)+"




[web2py] object is not callable

2012-04-24 Thread CtrlSoft
hi, my application on local host works fine but when i upload to server
i got this error


Traceback (most recent call last):
  File "/home/zerooo123/web2py/gluon/restricted.py", line 205, in restricted
exec ccode in environment
  File "/home/zerooo123/web2py/applications/orhei/controllers/default.py", line 
185, in 
  File "/home/zerooo123/web2py/gluon/globals.py", line 173, in 
self._caller = lambda f: f()
  File "/home/zerooo123/web2py/applications/orhei/controllers/default.py", line 
62, in menu
rows = db(db.articles.reference == 
int(request.args(0))).select(*articles,limitby=(0,30))
TypeError: 'NoneType' object is not callable



code listing:


def menu():
if lang == 'ru':
articles = [db.articles.title_ru, db.articles.added_on, db.articles.id]
elif lang == 'en': 
articles = [db.articles.title_en, db.articles.added_on, db.articles.id]
else:
articles = [db.articles.title_ro, db.articles.added_on, db.articles.id] 

rows = db(db.articles.reference == int(request 
.args(0))).select(*articles,limitby=(0,30))
return dict(row=db.menu[request 
.args(0)], rows = rows)






[web2py] Re: filename in dal

2012-04-22 Thread CtrlSoft

>
> oh, thanks, next time i will check the book before ask here :
>
>

[web2py] filename in dal

2012-04-22 Thread CtrlSoft
hi, it's possible in dal to write smth like this:
db.define_table("files",  
Field('file', 'upload', uploadfolder=request.folder+'static/docs'), 
Field('filename',type='string', default=request.vars.file.filename),
)


i tried but got some errors, can anyone help me



[web2py] process args

2012-04-09 Thread CtrlSoft
how to process args early than my model?

i want to split a unicode string that are in request.args for example:
in view:
"+str(b.title)+"

b.id = 15
b.title = "аыв ывташгытацуокц-"

in controller:
def menu():

#return dict(row=db.menu[request.args[0].split('-')[0]])

 # here i want to split request.args[0]# my url is looking like 
that "25-еннщшо ор зьлыв" 

s = str(request.args[0].split('-')[0])
return (s)

i tried in python IDE, and it is spliting but here...


[web2py] request.vars in DAL

2012-04-05 Thread CtrlSoft
hi i'm little confused with request. 
...
model:

db.define_table('menu',

Field('parent',type='integer', requires=IS_EMPTY_OR(IS_IN_DB(db, 'menu.id', 
'%(title)s'))),
Field('title', type='string',label=T('Title')),
Field('content', type='text',label=T('Content')),
Field('menu_type', type='string', default=request.vars.mtype, writable=False
) # it's is posible to pass vars in this mode?

.
 
)



def menu():
   table = request.args(0)
   mtype = request.vars.mtype
   grid = SQLFORM.grid(db[table].menu_type == mtype,args=request.args[:1])
   return dict(item=grid) 




in view:

 Top Menu
 Side Menu



 i want to hide row that are 'top' or ''side'', it works on select, but 
when i insert a new row in table(with sqlform.grid),
 i want also to hide in combobox field parent that has 
menu_type=request.vars.mtype









Re: [web2py] is_in_db two tables

2012-04-04 Thread CtrlSoft

>
> many thanks
>
>

[web2py] membership

2012-04-01 Thread CtrlSoft
how to hide tables based on user membership?

i have following functin in controller:
def view():
table = request.args(0)
grid = SQLFORM.grid(db[table],args=request.args[:1], ui = 
dict(widget='',
  header='',
  content='',
  default='',
  cornerall='',
  cornertop='',
  cornerbottom='',
  button='btn',
  buttontext='buttontext button',
  buttonadd='icon-plus',
  buttonback='icon-arrow-left',
  buttonexport='icon-file',
  buttondelete='icon-trash',
  buttonedit='icon-edit',
  buttontable='icon-arrow-right',
  buttonview='icon-eye-open'))
return dict(item=grid)

and in view:

   Top 
Menu
   Side 
Menu
   Articles
   Questions
   Answers 

i need that a specific user can edit specific table

Re: [web2py] is_in_db two tables

2012-04-01 Thread CtrlSoft
it's a good idea, but i'm using sqlform.grid in app admin and this will 
create confusion in rows ..., i need to hide rows that are in sidemenu or 
in top menu.  

[web2py] is_in_db two tables

2012-04-01 Thread CtrlSoft
i have the follwing tables:

db.define_table('topmenu',
Field('parent',type='integer', requires=IS_EMPTY_OR(IS_IN_DB(db, 
'topmenu.id', '%(title)s'))),
Field('link', type='string', label=T('Link')),
Field('title', type='string',label=T('Title Ro')),
Field('content', type='text',label=T('Content En')),
Field('added_on', 'date', default=request.now, 
requires=IS_DATE(format=T('%d-%m-%Y')), writable=False),
Field('updated_on', 'datetime', default=request.now, 
update=request.now, requires=IS_DATETIME(format=T('%d-%m-%Y %H:%M:%S')), 
 writable=False),
Field('public', 'boolean', default=True)

db.define_table('sidemenu',
Field('parent',type='integer', requires=IS_EMPTY_OR(IS_IN_DB(db, 
'sidemenu.id', '%(title)s'))),
Field('link', type='string', label=T('Link')),
Field('title', type='string',label=T('Title')),
Field('content', type='text',label=T('Content')),
Field('added_on', 'date', default=request.now, 
requires=IS_DATE(format=T('%d-%m-%Y')), writable=False),
Field('updated_on', 'datetime', default=request.now, 
update=request.now, requires=IS_DATETIME(format=T('%d-%m-%Y %H:%M:%S')), 
 writable=False),
Field('public', 'boolean', default=True)

how to reference table below with this 2 tables, 
db.define_table("articles",
Field('reference', db.sidemenu, requires=IS_IN_DB(db, 'sidemenu.id', 
'%(title)s')), *# here i need smth like : db.sidemenu | db.topmenu ... and 
is_in_db(db,'sidemenu.id' or 'topmenu.id')*
Field('image', 'upload'), 
Field("title",label=T('Title Ro'),requires=IS_NOT_EMPTY()),
Field("content" ,type='text',label=T('Content 
Ro'),requires=IS_NOT_EMPTY()),
Field('added_on', 'date', default=request.now, 
requires=IS_DATE(format=T('%d-%m-%Y')), writable=False),
Field('updated_on', 'datetime', default=request.now, 
update=request.now, requires=IS_DATETIME(format=T('%d-%m-%Y %H:%M:%S')), 
 writable=False),
Field('event', 'boolean', default=False),
Field('public', 'boolean', default=True))




[web2py] common row for multiple fildes names

2012-02-12 Thread Td CtrlSoft

in model:

db.define_table("news",
Field("title_en",requires=IS_NOT_EMPTY()),
Field("conten_en" ,type='text'),

Field("title_fr",requires=IS_NOT_EMPTY()),
Field("conten_fr" ,type='text'),

Field("title_de",requires=IS_NOT_EMPTY()),
Field("conten_de" ,type='text'),
#
Field('added_on', 'datetime', default=request.now, 
requires=IS_DATETIME(format=T('%d-%m-%Y %H:%M:%S'))),
Field('updated_on', 'datetime', default=request.now, 
update=request.now, requires=IS_DATETIME(format=T('%d-%m-%Y %H:%M:%S'

in controller:

if lang == 'de':
news = [db.news.title_de, db.news.conten_de]
elif lang == 'fr': 
news = [db.news.title_fr, db.news.conten_fr]
else:
news = [db.news.title_en, db.news.conten_en] 
 
rows = db(db.news).select(*news)
   #
return dict(row=rows)

in view:
here i need a common row something like 
{{=row.title}}
{{=row.content}}

so how can i create a common row object for different filds names? thx