Start repository

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

File added
# Except this file
!.gitignore
*.pyc
*.pyo
*.log
*~
#*
*.1
*.bak
*.bak2
*.w2p
*.swp
*.zip
\ No newline at end of file
Write something about this app.
Developed with web2py.
The web2py welcome app is licensed under public domain
(except for the css and js files that it includes, which have their own third party licenses).
You can modify this license when you add your own code.
T.force('en')
def index():
return dict()
@auth.requires(lambda: auth.has_membership('Administrator_back') or auth.has_membership('Specialist') or auth.has_membership('Manager') or auth.has_membership('General Manger'))
def users():
grid = SQLFORM.smartgrid(
db["admin_users"], linked_tables=['admin_membership'])
return dict(grid=grid)
@auth.requires(lambda: auth.has_membership('Administrator_back') or auth.has_membership('Specialist') or auth.has_membership('Manager') or auth.has_membership('General Manger'))
def roles():
grid = SQLFORM.smartgrid(db["admin_roles"], linked_tables=[
'admin_membership', 'admin_permission'])
return dict(grid=grid)
@auth.requires(lambda: auth.has_membership('Administrator_back') or auth.has_membership('Specialist') or auth.has_membership('Manager') or auth.has_membership('General Manger'))
def permission():
grid = SQLFORM.smartgrid(db["admin_permission"])
return dict(grid=grid)
@auth.requires(lambda: auth.has_membership('Administrator_back') or auth.has_membership('Specialist') or auth.has_membership('Manager') or auth.has_membership('General Manger'))
def membership():
grid = SQLFORM.smartgrid(db["admin_membership"])
return dict(grid=grid)
@auth.requires(lambda: auth.has_membership('Administrator_back') or auth.has_membership('Specialist') or auth.has_membership('Manager') or auth.has_membership('General Manger'))
def create_tables():
create_spatial_tables()
return dict(a=None)
\ No newline at end of file
T.force('en')
@auth.requires(lambda: auth.has_membership('Administrator_back') or auth.has_membership('Specialist') or auth.has_membership('Manager') or auth.has_membership('General Manger'))
def index():
session.active_method="index"
session.active_controller="amenities"
return dict(grid=SQLFORM.smartgrid(db.amenities, linked_tables=[], user_signature=False))
@auth.requires(lambda: (auth.has_membership('Administrator_back')) or (auth.has_membership('Specialist')) or (auth.has_membership('Manager')) or (auth.has_membership('General Manager')))
def delete():
countries = db(db.countries).select(db.countries.id, db.countries.country)
form = FORM(
_action=URL("amenities","/massive_delete_amenities")
,_method="post"
,*[DIV(_class='form-group',
*[
LABEL(
"Select a country:", _class='col-xs-12', _for="country_code"
),
SELECT(
_name='country_code'
,_id="country_code"
, *[OPTION(countries[i].country, _value=str(countries[i].id)) for i in range(len(countries))], _class="form-control")
]
)
, DIV(_class='form-group',
*[
LABEL(
"Select a city:", _class='col-xs-12', _for="city_code"
)
,SELECT(
_name='city_code', _id="city_code", _class="form-control")
]
)
, DIV(_class='form-group',
*[
INPUT(_type='submit',
_class="col-xs-12 col-sm-6 col-md-4 col-lg-3 btn btn-default")
]
)
]
)
return dict(form=form)
@auth.requires(lambda: (auth.has_membership('Administrator_back')) or (auth.has_membership('Specialist')) or (auth.has_membership('Manager')) or (auth.has_membership('General Manager')))
def massive_delete_amenities():
data={}
message=''
try:
data['country_code'] = request.post_vars.country_code
data['city_code'] = request.post_vars.city_code
data['user_id']=auth.user_id
db((db.amenities.country_code==data['country_code']) & (db.amenities.city_code==data['city_code'])).delete()
message += T("All amenities where deleted correctly")
session.status = True
except Exception as e:
message=T("There was an error while deleting the amenities")+" "+str(e)
session.status = False
session.message=message
redirect(URL("amenities","index"))
\ No newline at end of file
This diff is collapsed.
T.force('en')
@auth.requires(lambda: auth.has_membership('Administrator_back') or auth.has_membership('Specialist') or auth.has_membership('Manager') or auth.has_membership('General Manger'))
def index():
session.active_method = "index"
session.active_controller = "buffers"
return dict(grid=SQLFORM.smartgrid(db.buffers, linked_tables=[], user_signature=False))
@auth.requires(lambda: auth.has_membership('Administrator_back') or auth.has_membership('Specialist') or auth.has_membership('Manager') or auth.has_membership('General Manger'))
def import_csv():
countries = db(db.countries).select(
db.countries.id, db.countries.country)
form = FORM(
_action=URL("buffers", "/process_csv"), _method="post", *[
DIV(_class='form-group',
*[
LABEL(
"Select a country:", _class='col-xs-12', _for="country_code"
),
SELECT(_name='country_code', _id="country_code", *[OPTION(countries[i].country, _value=str(countries[i].id)) for i in range(len(countries))], _class="form-control")
]
),
DIV(_class='form-group',
*[
LABEL(
"Select a city:", _class='col-xs-12', _for="city_code"
),
SELECT(_name='city_code', _id="city_code",
_class="form-control")
]
),
DIV(_class='form-group',
*[
LABEL(
"Select a file:", _class='col-xs-12', _for="csv_file"
), INPUT(
_type='file',
_name='csv_file', _id="csv_file", _class="", _accept=".csv")
]
), DIV(_class='form-group',
*[
INPUT(_type='submit',
_class="col-xs-12 col-sm-6 col-md-4 col-lg-3")
]
)
]
)
return dict(form=form)
@auth.requires(lambda: auth.has_membership('Administrator_back') or auth.has_membership('Specialist') or auth.has_membership('Manager') or auth.has_membership('General Manger'))
def process_csv():
response.generic_patterns = ['*']
message = ''
import csv
import shutil
import pandas as pd
import os
try:
filename = request.vars.csv_file.filename
file = request.vars.csv_file.file
file_name = request.env.web2py_path + '/applications/'+request.application+'/uploads/' + filename
shutil.copyfileobj(file, open(file_name, "wb"))
message += T("The file was uploaded successfully ")
data = pd.read_csv(file_name, sep=",", encoding='utf-8', quotechar='"')
data['country_code'] = request.post_vars.country_code
data['city_code'] = request.post_vars.city_code
data['user_id'] = auth.user_id
csv.field_size_limit(data.transit.map(lambda x: len(x)).max())
data.to_csv(file_name, sep=',', encoding='utf-8', index=False,
doublequote=True, quotechar='"', quoting=csv.QUOTE_MINIMAL)
db.buffers.import_from_csv_file(open(file_name))