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 %(appname)s installed with md5sum: %(digest)s': 'application %(appname)s installed with md5sum: %(digest)s',
|
||||
'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 name:': 'Nombre de la aplicación:',
|
||||
'are not used': 'are not used',
|
||||
@@ -63,6 +64,7 @@
|
||||
'cache': 'cache',
|
||||
'cache, errors and sessions cleaned': 'cache, errores y sesiones eliminados',
|
||||
'can be a git repo': 'puede ser un repositorio git',
|
||||
'Cancel': 'Cancel',
|
||||
'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:': 'No se puede compilar: hay errores en su aplicación:',
|
||||
@@ -161,6 +163,7 @@
|
||||
'Error snapshot': 'Error snapshot',
|
||||
'Error ticket': 'Error ticket',
|
||||
'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',
|
||||
'Exit Fullscreen': 'Exit Fullscreen',
|
||||
'Expand Abbreviation': 'Expand Abbreviation',
|
||||
|
||||
@@ -186,6 +186,10 @@ def select():
|
||||
import re
|
||||
db = get_database(request)
|
||||
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+)')
|
||||
if len(request.args) > 1 and hasattr(db[request.args[1]], '_primarykey'):
|
||||
regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>.+)')
|
||||
@@ -203,7 +207,15 @@ def select():
|
||||
else:
|
||||
start = 0
|
||||
nrows = 0
|
||||
stop = start + 100
|
||||
|
||||
step = 100
|
||||
fields = []
|
||||
|
||||
if is_imap:
|
||||
step = 3
|
||||
|
||||
stop = start + step
|
||||
|
||||
table = None
|
||||
rows = []
|
||||
orderby = request.vars.orderby
|
||||
@@ -244,12 +256,18 @@ def select():
|
||||
db(query, ignore_common_filters=True).delete()
|
||||
response.flash = T('%s %%{row} deleted', nrows)
|
||||
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:
|
||||
rows = db(query, ignore_common_filters=True).select(limitby=(
|
||||
start, stop), orderby=eval_in_global_env(orderby))
|
||||
rows = db(query, ignore_common_filters=True).select(
|
||||
*fields, limitby=(start, stop),
|
||||
orderby=eval_in_global_env(orderby))
|
||||
else:
|
||||
rows = db(query, ignore_common_filters=True).select(
|
||||
limitby=(start, stop))
|
||||
*fields, limitby=(start, stop))
|
||||
except Exception, e:
|
||||
import traceback
|
||||
tb = traceback.format_exc()
|
||||
@@ -278,11 +296,12 @@ def select():
|
||||
table=table,
|
||||
start=start,
|
||||
stop=stop,
|
||||
step=step,
|
||||
nrows=nrows,
|
||||
rows=rows,
|
||||
query=request.vars.query,
|
||||
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>
|
||||
<br/><br/>
|
||||
<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 stop<nrows:}}{{=A(T('next 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 %s rows') % step,_href=URL('select',args=request.args[0],vars=dict(start=start+step)),_class="btn")}}{{pass}}
|
||||
{{if rows:}}
|
||||
<div style="overflow: auto;" width="80%">
|
||||
{{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:
|
||||
self.db.define_table("%s" % name,
|
||||
Field("uid", "string", writable=False),
|
||||
Field("answered", "boolean"),
|
||||
Field("uid", writable=False),
|
||||
Field("created", "datetime", writable=False),
|
||||
Field("content", list, writable=False),
|
||||
Field("to", "string", writable=False),
|
||||
Field("cc", "string", writable=False),
|
||||
Field("bcc", "string", writable=False),
|
||||
Field("content", "text", writable=False),
|
||||
Field("to", writable=False),
|
||||
Field("cc", writable=False),
|
||||
Field("bcc", writable=False),
|
||||
Field("sender", 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("draft", "boolean"),
|
||||
Field("flagged", "boolean"),
|
||||
Field("sender", "string", writable=False),
|
||||
Field("recent", "boolean", writable=False),
|
||||
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)
|
||||
Field("seen", "boolean")
|
||||
)
|
||||
|
||||
# Set a special _mailbox attribute for storing
|
||||
@@ -6562,7 +6562,7 @@ class IMAPAdapter(NoSQLAdapter):
|
||||
|
||||
mailbox = table.mailbox
|
||||
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()
|
||||
if len(d) > 0:
|
||||
message = d.get("email", None)
|
||||
|
||||
Reference in New Issue
Block a user