...
 
Commits (6)
IMAGE_TAG=0.20-beta
IMAGE_TAG=0.21-beta
......@@ -67,7 +67,7 @@ class StarInfo(Base):
'mode_id': F_DUMP,
'fields': {
'ID1': { 'field': 'id1', 'must': True, 'check': 'check_star' },
'ID2': { 'field': 'id2', 'must': True, 'check': 'check_star' },
'ID2': { 'field': 'id2', 'must': True, 'check': 'check_star2' },
'UD_DIAM': { 'field': 'ud_diam', 'must': True, 'check': 'check_float', 'alternate': 'UD_MEAS' },
'UD_MEAS': { 'field': 'ud_diam', 'check': 'check_float' },
'LD_DIAM': { 'field': 'ld_diam', 'must': True, 'check': 'check_float', 'alternate': 'LD_MEAS' },
......@@ -182,6 +182,10 @@ class StarInfo(Base):
self.errors[field] = f_err
f_err.append(msg)
def has_problem(self, field):
return self.problem_fields and field in self.problem_fields
def append_entry_error(self, msg):
self.append_error('_', msg)
......@@ -253,10 +257,11 @@ class StarInfo(Base):
# print("setting value '%s' to object variable '%s'"%(str(value), field_name))
setattr(self, field_name, value)
def check_star(self, field_name, field_info, value):
def check_star(self, field_name, field_info, value, accept_empty_value=False):
# print("Checking star '%s' for field '%s'"%(value, field_name))
if not value:
self.append_error(field_name, 'star identifier not set')
if not accept_empty_value :
self.append_error(field_name, 'star identifier not set')
return
try:
star = self.query_starname(value)
......@@ -269,6 +274,10 @@ class StarInfo(Base):
self.set_field_value(field_var+'_id', star.id)
self.set_field_value(field_var, value)
def check_star2(self, field_name, field_info, value):
self.check_star(field_name, field_info, value, True)
def check_float(self, field_name, field_info, value):
if isinstance(value, str):
if not value:
......@@ -446,20 +455,22 @@ class StarInfo(Base):
if warning:
self.append_warning('band', warning)
if error:
self.append_error('band', error)
# Report error only if associated band_code is not valid
if self.has_problem('band_code'):
self.append_error('band', error)
else:
self.append_warning('band', error)
if isinstance(bc, float) or isinstance(bc, int):
# some lines have band_code -1
if self.band_code is not None and self.band_code != -1:
if self.band_code != bc:
self.append_error('band', 'calculated band_code %s differs from given band_code %s'%(str(bc), str(self.band_code)))
else:
self.append_warning('band', 'calculated band_code %s matches with given band_code %s'%(str(bc), str(self.band_code)))
else:
# there was no band_code given but bc seems ok.
# GM: do not throw an error since next affection seems nice.
# self.append_error('band', 'calculated band_code %s'%(repr(bc)))
self.band_code = bc
else:
elif bc:
self.append_error('band', 'calculated band_code invalid \'%s\''%(repr(bc)))
#
......
......@@ -84,6 +84,12 @@ body > * {
}
/* entry logs */
.hidden {
display:none!important;
visibility:hidden!important
}
.entry-info .entry-log:nth-child(even){
background-color: lightyellow;
}
......@@ -129,4 +135,4 @@ textarea {
width: -webkit-fill-available;
width: stretch;
height: 30em;
}
\ No newline at end of file
}
{% if entries %}
<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>
<div class="entry-info">
{% for entry in entries %}
{% if entry.entry.warnings or entry.entry.errors or not entry.entry.unique %}
{% if entry.entry.errors %}
<div class="entry-log">
{% else %}
<div class="entry-log erroronly">
{% endif %}
<div class="line">
<div class="lineno">{{entry.line+1}}</div>
<div class="messages">
......
from pyramid.response import Response
#from pyramid.response import Response
from pyramid.view import view_config
from sqlalchemy.exc import DBAPIError
#from sqlalchemy.exc import DBAPIError
from jmdc_app.models.star_info import StarInfo
......@@ -8,7 +8,7 @@ from jmdc_app.models.star_info import StarInfo
def jmdc_home(request):
session = request.dbsession
stars = session.query(StarInfo).all()
# order by id (creation order / look during import )
stars = session.query(StarInfo).order_by(StarInfo.id).all()
return { 'stars': stars }
\ No newline at end of file
......@@ -70,7 +70,7 @@ class ImportProcess(threading.Thread):
print("submission_id = %d, email = %s"%(self.sub.id, self.sub.email))
print("headers(%d) %4d : %s"%(self.sub.parse_mode, self.sub.id, self.sub.headers))
headers = json.loads(self.sub.headers)
entries = session.query(StarInfoEntry).filter_by(submission_id=self.sub.id).all()
entries = session.query(StarInfoEntry).filter_by(submission_id=self.sub.id).order_by(StarInfoEntry.line_number).all()
errors_present = False
for entry in entries:
......