Merge pull request #268 from spametki/master
imap: use common field types plus appadmin support
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
'application "%s" uninstalled': 'aplicación "%s" desinstalada',
|
'application "%s" uninstalled': 'aplicación "%s" desinstalada',
|
||||||
'application %(appname)s installed with md5sum: %(digest)s': 'application %(appname)s installed with md5sum: %(digest)s',
|
'application %(appname)s installed with md5sum: %(digest)s': 'application %(appname)s installed with md5sum: %(digest)s',
|
||||||
'application compiled': 'aplicación compilada',
|
'application compiled': 'aplicación compilada',
|
||||||
|
'Application exists already': 'Application exists already',
|
||||||
'application is compiled and cannot be designed': 'la aplicación está compilada y no puede ser modificada',
|
'application is compiled and cannot be designed': 'la aplicación está compilada y no puede ser modificada',
|
||||||
'Application name:': 'Nombre de la aplicación:',
|
'Application name:': 'Nombre de la aplicación:',
|
||||||
'are not used': 'are not used',
|
'are not used': 'are not used',
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
'cache': 'cache',
|
'cache': 'cache',
|
||||||
'cache, errors and sessions cleaned': 'cache, errores y sesiones eliminados',
|
'cache, errors and sessions cleaned': 'cache, errores y sesiones eliminados',
|
||||||
'can be a git repo': 'puede ser un repositorio git',
|
'can be a git repo': 'puede ser un repositorio git',
|
||||||
|
'Cancel': 'Cancel',
|
||||||
'Cannot be empty': 'No puede estar vacío',
|
'Cannot be empty': 'No puede estar vacío',
|
||||||
'Cannot compile: there are errors in your app. Debug it, correct errors and try again.': 'No se puede compilar: hay errores en su aplicación. Depure, corrija errores y vuelva a intentarlo.',
|
'Cannot compile: there are errors in your app. Debug it, correct errors and try again.': 'No se puede compilar: hay errores en su aplicación. Depure, corrija errores y vuelva a intentarlo.',
|
||||||
'Cannot compile: there are errors in your app:': 'No se puede compilar: hay errores en su aplicación:',
|
'Cannot compile: there are errors in your app:': 'No se puede compilar: hay errores en su aplicación:',
|
||||||
@@ -161,6 +163,7 @@
|
|||||||
'Error snapshot': 'Error snapshot',
|
'Error snapshot': 'Error snapshot',
|
||||||
'Error ticket': 'Error ticket',
|
'Error ticket': 'Error ticket',
|
||||||
'Errors': 'errores',
|
'Errors': 'errores',
|
||||||
|
'Errors in form, please check it out.': 'Errors in form, please check it out.',
|
||||||
'Exception instance attributes': 'Atributos de la instancia de Excepción',
|
'Exception instance attributes': 'Atributos de la instancia de Excepción',
|
||||||
'Exit Fullscreen': 'Exit Fullscreen',
|
'Exit Fullscreen': 'Exit Fullscreen',
|
||||||
'Expand Abbreviation': 'Expand Abbreviation',
|
'Expand Abbreviation': 'Expand Abbreviation',
|
||||||
|
|||||||
@@ -186,6 +186,10 @@ def select():
|
|||||||
import re
|
import re
|
||||||
db = get_database(request)
|
db = get_database(request)
|
||||||
dbname = request.args[0]
|
dbname = request.args[0]
|
||||||
|
try:
|
||||||
|
is_imap = db._uri.startswith("imap://")
|
||||||
|
except (KeyError, AttributeError, TypeError):
|
||||||
|
is_imap = False
|
||||||
regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>\d+)')
|
regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>\d+)')
|
||||||
if len(request.args) > 1 and hasattr(db[request.args[1]], '_primarykey'):
|
if len(request.args) > 1 and hasattr(db[request.args[1]], '_primarykey'):
|
||||||
regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>.+)')
|
regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>.+)')
|
||||||
@@ -203,7 +207,15 @@ def select():
|
|||||||
else:
|
else:
|
||||||
start = 0
|
start = 0
|
||||||
nrows = 0
|
nrows = 0
|
||||||
stop = start + 100
|
|
||||||
|
step = 100
|
||||||
|
fields = []
|
||||||
|
|
||||||
|
if is_imap:
|
||||||
|
step = 3
|
||||||
|
|
||||||
|
stop = start + step
|
||||||
|
|
||||||
table = None
|
table = None
|
||||||
rows = []
|
rows = []
|
||||||
orderby = request.vars.orderby
|
orderby = request.vars.orderby
|
||||||
@@ -244,12 +256,18 @@ def select():
|
|||||||
db(query, ignore_common_filters=True).delete()
|
db(query, ignore_common_filters=True).delete()
|
||||||
response.flash = T('%s %%{row} deleted', nrows)
|
response.flash = T('%s %%{row} deleted', nrows)
|
||||||
nrows = db(query, ignore_common_filters=True).count()
|
nrows = db(query, ignore_common_filters=True).count()
|
||||||
|
|
||||||
|
if is_imap:
|
||||||
|
fields = [db[table][name] for name in
|
||||||
|
("id", "uid", "created", "to",
|
||||||
|
"sender", "subject")]
|
||||||
if orderby:
|
if orderby:
|
||||||
rows = db(query, ignore_common_filters=True).select(limitby=(
|
rows = db(query, ignore_common_filters=True).select(
|
||||||
start, stop), orderby=eval_in_global_env(orderby))
|
*fields, limitby=(start, stop),
|
||||||
|
orderby=eval_in_global_env(orderby))
|
||||||
else:
|
else:
|
||||||
rows = db(query, ignore_common_filters=True).select(
|
rows = db(query, ignore_common_filters=True).select(
|
||||||
limitby=(start, stop))
|
*fields, limitby=(start, stop))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
import traceback
|
import traceback
|
||||||
tb = traceback.format_exc()
|
tb = traceback.format_exc()
|
||||||
@@ -278,11 +296,12 @@ def select():
|
|||||||
table=table,
|
table=table,
|
||||||
start=start,
|
start=start,
|
||||||
stop=stop,
|
stop=stop,
|
||||||
|
step=step,
|
||||||
nrows=nrows,
|
nrows=nrows,
|
||||||
rows=rows,
|
rows=rows,
|
||||||
query=request.vars.query,
|
query=request.vars.query,
|
||||||
formcsv=formcsv,
|
formcsv=formcsv,
|
||||||
tb=tb,
|
tb=tb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,8 @@
|
|||||||
{{=T('"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN')}}</p>
|
{{=T('"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN')}}</p>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<h4>{{=T("%s selected", nrows)}}</h4>
|
<h4>{{=T("%s selected", nrows)}}</h4>
|
||||||
{{if start>0:}}{{=A(T('previous 100 rows'),_href=URL('select',args=request.args[0],vars=dict(start=start-100)),_class="btn")}}{{pass}}
|
{{if start>0:}}{{=A(T('previous %s rows') % step,_href=URL('select',args=request.args[0],vars=dict(start=start-step)),_class="btn")}}{{pass}}
|
||||||
{{if stop<nrows:}}{{=A(T('next 100 rows'),_href=URL('select',args=request.args[0],vars=dict(start=start+100)),_class="btn")}}{{pass}}
|
{{if stop<nrows:}}{{=A(T('next %s rows') % step,_href=URL('select',args=request.args[0],vars=dict(start=start+step)),_class="btn")}}{{pass}}
|
||||||
{{if rows:}}
|
{{if rows:}}
|
||||||
<div style="overflow: auto;" width="80%">
|
<div style="overflow: auto;" width="80%">
|
||||||
{{linkto = lambda f, t, r: URL('update', args=[request.args[0], r, f]) if f else "#"}}
|
{{linkto = lambda f, t, r: URL('update', args=[request.args[0], r, f]) if f else "#"}}
|
||||||
|
|||||||
+14
-14
@@ -6281,25 +6281,25 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
self.db.define_table("%s" % name,
|
self.db.define_table("%s" % name,
|
||||||
Field("uid", "string", writable=False),
|
Field("uid", writable=False),
|
||||||
Field("answered", "boolean"),
|
|
||||||
Field("created", "datetime", writable=False),
|
Field("created", "datetime", writable=False),
|
||||||
Field("content", list, writable=False),
|
Field("content", "text", writable=False),
|
||||||
Field("to", "string", writable=False),
|
Field("to", writable=False),
|
||||||
Field("cc", "string", writable=False),
|
Field("cc", writable=False),
|
||||||
Field("bcc", "string", writable=False),
|
Field("bcc", writable=False),
|
||||||
|
Field("sender", writable=False),
|
||||||
Field("size", "integer", writable=False),
|
Field("size", "integer", writable=False),
|
||||||
|
Field("subject", writable=False),
|
||||||
|
Field("mime", writable=False),
|
||||||
|
Field("email", "text", writable=False, readable=False),
|
||||||
|
Field("attachments", "text", writable=False, readable=False),
|
||||||
|
Field("encoding", writable=False),
|
||||||
|
Field("answered", "boolean"),
|
||||||
Field("deleted", "boolean"),
|
Field("deleted", "boolean"),
|
||||||
Field("draft", "boolean"),
|
Field("draft", "boolean"),
|
||||||
Field("flagged", "boolean"),
|
Field("flagged", "boolean"),
|
||||||
Field("sender", "string", writable=False),
|
|
||||||
Field("recent", "boolean", writable=False),
|
Field("recent", "boolean", writable=False),
|
||||||
Field("seen", "boolean"),
|
Field("seen", "boolean")
|
||||||
Field("subject", "string", writable=False),
|
|
||||||
Field("mime", "string", writable=False),
|
|
||||||
Field("email", "string", writable=False, readable=False),
|
|
||||||
Field("attachments", list, writable=False, readable=False),
|
|
||||||
Field("encoding", writable=False)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set a special _mailbox attribute for storing
|
# Set a special _mailbox attribute for storing
|
||||||
@@ -6562,7 +6562,7 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
|
|
||||||
mailbox = table.mailbox
|
mailbox = table.mailbox
|
||||||
d = dict(((k.name, v) for k, v in fields))
|
d = dict(((k.name, v) for k, v in fields))
|
||||||
date_time = d.get("created", datetime.datetime.now())
|
date_time = d.get("created") or datetime.datetime.now()
|
||||||
struct_time = date_time.timetuple()
|
struct_time = date_time.timetuple()
|
||||||
if len(d) > 0:
|
if len(d) > 0:
|
||||||
message = d.get("email", None)
|
message = d.get("email", None)
|
||||||
|
|||||||
Reference in New Issue
Block a user