...
 
Commits (6)
IMAGE_TAG=0.21-beta
IMAGE_TAG=0.22-beta
......@@ -222,17 +222,19 @@ class StarName(Base):
[ '%s'%(name), 'like' ],
[ '* %s'%(name), 'like' ],
[ '* %s'%(name).lower(), 'ilike' ],
[ 'V* %s'%(name), 'like' ],
[ 'V* %s'%(name).lower(), 'ilike' ]
[ 'V* %s'%(name), 'like' ]
# comment since it can cause confusion [ 'V* %s'%(name).lower(), 'ilike' ]
# fault case was for mu GEM that differs from v* mu gem
]
for search in SEARCH_ALGS:
search_string, mode = search
if mode =='like':
sn = session.query(StarName).filter(StarName.name.like(search_string)).first()
print("looking for name '%s' -> '%s'" % (search_string, repr(sn)))
if mode == 'ilike':
sn = session.query(StarName).filter(StarName.name.ilike(search_string)).first()
print("looking for name '%s' -> '%s'"%(search_string, repr(sn)))
print("looking for name '%s' -> '%s'" % (search_string, repr(sn)))
if sn:
return (sn.star_id, sn.name, )
......
......@@ -5,6 +5,6 @@
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}"/>
<div>{{form.email.label}} {{form.email}}</div>
<div>{{form.import_file.label}} {{form.import_file}}</div>
<div><button type="submit">envoyer</button></div>
<div><button type="submit">Submit</button></div>
</form>
{% endblock submit_form %}
\ No newline at end of file
{% if entries %}
{% if has_problem %}
<a onclick="$(&quot;.erroronly&quot;).toggleClass(&quot;hidden&quot;);" class="dt-button"><span class="erroronly btn btn-warning btn-xs hidden">show all</span><span class="erroronly btn btn-success btn-xs">show error only</span></a>
{% endif %}
<div class="entry-info">
{% for entry in entries %}
{% if entry.entry.warnings or entry.entry.errors or not entry.entry.unique %}
{% if entry.entry.warnings or entry.entry.errors or entry.entry.unique %}
{% if entry.entry.errors %}
<div class="entry-log">
{% else %}
......
......@@ -5,6 +5,6 @@
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}"/>
<div>{{form.email.label}} {{form.email}}</div>
<div>{{form.csv_data.label}}<br/>{{form.csv_data}}</div>
<div><button type="submit">envoyer</button></div>
<div><button type="submit">Submit</button></div>
</form>
{% endblock submit_form %}
\ No newline at end of file
......@@ -20,13 +20,13 @@ from jmdc_app.models.star_info import StarInfo
from jmdc_app.models.submission import StarInfoEntry, Submission
def send_email_to_moderator(mailer, moderate_url, submission):
def send_email_to_moderator(settings, moderate_url):
# send email to moderator
#moderate_url = request.route_path('moderate-submission', token=submission.moderate_ticket)
print("DEBUG: moderation url %s"%(moderate_url))
try:
sender = request.registry.settings['jmdc.sender.email']
moderator = request.registry.settings['jmdc.moderator.email']
sender = settings['jmdc.sender.email']
moderator = settings['jmdc.moderator.email']
except:
print("DEBUG: no mail sent for moderator %s"%(moderate_url))
else:
......@@ -34,7 +34,7 @@ def send_email_to_moderator(mailer, moderate_url, submission):
# TODO: change the mail subject
message = Message(subject="there is one submission to moderate", sender=sender,
recipients=[moderator],
body="There is a new submission at JMDC, moderation can be done here : \n %s \nRegards!"%moderate_url)
body="There is a new submission at JMDC, moderation can be done here : \n %s \nRegards!"%moderate_url)
mailer = Mailer.from_settings(settings)
mailer.send(message)
......@@ -46,12 +46,12 @@ class ImportProcess(threading.Thread):
we can't pass the submission object here, only the id
"""
def __init__(self, settings, sub):
def __init__(self, settings, sub, moderate_url):
super().__init__()
self.settings = settings
self.sub_id = sub.id
self.sub = None
self.moderate_url = ''
self.moderate_url = moderate_url
def async_import_process(self):
count = 0
......@@ -116,7 +116,7 @@ class ImportProcess(threading.Thread):
# send email to moderator (async run) only if there were no errors in the process above
if not errors_present:
send_email_to_moderator(self.settings, self.moderate_url, self.sub)
send_email_to_moderator(self.settings, self.moderate_url)
else:
print("we had errors in the file, not sending mail to moderator")
......@@ -129,8 +129,8 @@ class ImportProcess(threading.Thread):
def start_import_process(request, submission):
print("Start the import process thread")
t = ImportProcess(request.registry.settings, submission)
t.moderate_url = request.route_path('moderate-submission', token=submission.moderate_ticket)
moderate_url = request.route_path('moderate-submission', token=submission.moderate_ticket)
t = ImportProcess(request.registry.settings, submission, moderate_url)
t.daemon = True
t.start()
......@@ -164,7 +164,6 @@ def moderate_submission(request):
submission.verified = True
just_verified = True
# launch the worker process after the data is committed
if run_async:
if not submission.processing:
......@@ -175,10 +174,9 @@ def moderate_submission(request):
else:
# send email to moderator (in case of not running async)
moderate_url = request.route_path('moderate-submission', token=submission.moderate_ticket)
send_email_to_moderator(request.mailer, moderate_url, submission)
send_email_to_moderator(request.registry.settings, moderate_url)
pass
if just_verified:
session.commit()
......@@ -213,6 +211,7 @@ def moderate_submission(request):
if k not in problem_fields:
problem_fields.append(k)
problem_fields.sort()
context['has_problem'] = True
entry['problem_fields'] = problem_fields
entries.append({'line': e.line_number-1, 'entry': entry})
context['entries'] = entries
......@@ -304,6 +303,6 @@ def get_line_form(request):
print("%d lines contain errors"%(nb_errors))
if nb_errors == 0:
moderate_url = request.route_url('moderate-submission', token=submission.moderate_ticket)
send_email_to_moderator(request.registry.settings, moderate_url, submission)
send_email_to_moderator(request.registry.settings, moderate_url)
return render_to_response(renderer, context)