Skip to content

Commit

Permalink
Moved gerber and DXF into refdocfs. Implemented AM-printable regenera…
Browse files Browse the repository at this point in the history
…tion.
  • Loading branch information
chintal committed Nov 20, 2015
1 parent 6bed957 commit f46a173
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
25 changes: 25 additions & 0 deletions tendril/dox/production.py
Expand Up @@ -36,10 +36,14 @@
import os
import yaml

from fs.utils import copyfile

from tendril.boms import electronics as boms_electronics
from tendril.entityhub import projects
from tendril.entityhub import serialnos
from tendril.gedaif.conffile import ConfigsFile
from tendril.utils.fsutils import temp_fs
from tendril.utils.fsutils import get_tempname
from tendril.utils.pdf import merge_pdf

import render
Expand Down Expand Up @@ -294,3 +298,24 @@ def get_production_order_data(serialno=None):
snomap_data = yaml.load(f)

return order_yaml_data, snomap_data


def get_production_order_manifest_set(serialno):
workspace = temp_fs.makeopendir(get_tempname())
children = serialnos.get_child_serialnos(sno=serialno)
manifests = []
for child in children:
am = docstore.get_docs_list_for_sno_doctype(child, 'ASSEMBLY MANIFEST')
if len(am) == 1:
am = am[0]
copyfile(am.fs, am.path, workspace, am.filename, overwrite=True)
manifests.append(workspace.getsyspath(am.filename))
if len(manifests):
output = merge_pdf(manifests,
os.path.join(
workspace.getsyspath('/'),
serialno + '.pdf'
),
remove_sources=True)
return output
return None
2 changes: 1 addition & 1 deletion tendril/entityhub/serialnos.py
Expand Up @@ -85,7 +85,7 @@ def get_parent_serialnos(sno=None, session=None):
def get_child_serialnos(sno=None, session=None):
if sno is None:
raise AttributeError("child cannot be None")
return controller.get_serialno_object(sno=sno, session=session).children
return controller.get_child_snos(serialno=sno, session=session)


@with_db
Expand Down
Expand Up @@ -25,7 +25,7 @@ <h3>{{ stage.order_yaml.title }}</h3>

<div class="small-12 medium-6 columns" data-magellan-destination="order">
<a name="order"></a>

<div class="small-12 columns">
<div class="small-12 columns text-center">
<h5>Modules for Production</h5>
Expand Down Expand Up @@ -53,15 +53,15 @@ <h5>Modules for Production</h5>
var table = $('#order_table').DataTable({
/* Disable initial sort */
"aaSorting": [],
{% include 'parts/datatable_defaults.html' %}
{% include 'parts/datatable_defaults.html' %}
});
table.buttons().container()
.appendTo( '#order_table_wrapper .small-12.medium-6.columns:eq(0)' );
});
</script>
</div>


<div class="small-12 columns panel radius">
<div class="small-12 columns text-center">
<h5>Related Documentation</h5>
Expand All @@ -73,9 +73,14 @@ <h5>Related Documentation</h5>
<div class="text-center"><b>{{ stage.order_indentsno }}</b></div>
</div>
</a>
<a href="/production/manifests/{{ stage.order_sno }}">
<div class="button radius small-12 columns active-tb shadow mrgn-20-top">
<div class="text-center">Collated Assembly Manifests</div>
</div>
</a>
</div>
</div>

</div>

<div class="small-12 medium-6 columns" data-magellan-destination="documentation">
Expand Down Expand Up @@ -105,7 +110,7 @@ <h5> Serial Number Map </h5>
{% endfor %}
<li></li>
</ul>
</div>
</div>
</div>


Expand Down
11 changes: 11 additions & 0 deletions tendril/frontend/blueprints/production/views.py
Expand Up @@ -24,13 +24,24 @@

from flask import render_template
from flask_user import login_required
from flask import abort
from flask import send_file

from . import production as blueprint

from tendril.dox import production as dxproduction
from tendril.utils.fsutils import Crumb


@blueprint.route('/manifests/<order_sno>')
def manifests(order_sno=None):
if not order_sno:
abort(404)
rfile = dxproduction.get_production_order_manifest_set(order_sno)
# TODO figure out how to delete this file later on.
return send_file(rfile, as_attachment=True)


@blueprint.route('/order/<order_sno>')
@blueprint.route('/order/')
@login_required
Expand Down

0 comments on commit f46a173

Please sign in to comment.