Browse Source

Add public view

master
Dashie der otter 3 years ago
parent
commit
8f6debc39b

+ 2
- 0
config.py.sample View File

@@ -37,4 +37,6 @@ PAG_PARTS_DISTRIB = 10
PAG_PARTS_MANUF = 10
PAG_PARTS = 10

STOCKAZ_PUBLIC = False

UPLOADS_DEFAULT_DEST = '/Users/dashie/dev/StockazNG/uploads/attachments/'

+ 3
- 0
controllers/parts.py View File

@@ -47,6 +47,8 @@ def parts_new():
a.status = form.status.data
a.condition = form.condition.data
a.needs_review = form.needs_review.data
a.private = form.private.data

a.can_be_sold = form.can_be_sold.data

# Force category to uncategorized, idiot
@@ -102,6 +104,7 @@ def parts_edit(pid):
a.condition = form.condition.data
a.needs_review = form.needs_review.data
a.can_be_sold = form.can_be_sold.data
a.private = form.private.data

a.part_category = category
a.footprint_id = None if form.footprint.raw_data[0] == '__None' else form.footprint.raw_data[0] # FIXME ewwww

+ 6
- 0
controllers/views.py View File

@@ -22,3 +22,9 @@ def view_storages():
def parts_to_sold():
return render_template('view/parts_to_sold.jinja2',
parts=Part.query.order_by('name').filter(Part.can_be_sold == True).all())


@bp_views.route('/parts/public')
def parts_public():
return render_template('view/parts_public.jinja2',
parts=Part.query.order_by('name').filter(Part.private == False).all())

+ 1
- 0
forms.py View File

@@ -44,6 +44,7 @@ class PartForm(ModelForm):

needs_review = BooleanField('Needs review')
can_be_sold = BooleanField('Can be sold')
private = BooleanField('Private')

part_measurement_unit = QuerySelectField(default=default_pmu,
query_factory=get_part_measurement_units,

+ 26
- 0
migrations/versions/3a3e70cbc864_.py View File

@@ -0,0 +1,26 @@
"""Add private column

Revision ID: 3a3e70cbc864
Revises: 49f64ff8b271
Create Date: 2015-10-12 13:48:37.452356

"""

# revision identifiers, used by Alembic.
revision = '3a3e70cbc864'
down_revision = '49f64ff8b271'

from alembic import op
import sqlalchemy as sa


def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('part', sa.Column('private', sa.Boolean(), nullable=True))
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('part', 'private')
### end Alembic commands ###

+ 1
- 0
models.py View File

@@ -333,6 +333,7 @@ class Part(db.Model):
barcode_str = db.Column(db.String(13), nullable=True, info={'label': 'Barcode string'}, default="0000000000000")

can_be_sold = db.Column(db.Boolean(), default=False, info={'label': 'Can be sold'})
private = db.Column(db.Boolean(), default=False, info={'label': 'Private part'})

part_category_id = db.Column(db.Integer(), db.ForeignKey('part_category.id'), nullable=False)
footprint_id = db.Column(db.Integer(), db.ForeignKey('footprint.id'), nullable=True)

+ 2
- 1
stockazng.py View File

@@ -92,7 +92,8 @@ def before_request():
'PAG_PARTS_MANUF': app.config['PAG_PARTS_MANUF'],
'PAG_PARTS': app.config['PAG_PARTS'],
'PAG_UNITS': app.config['PAG_UNITS'],
'STOCKAZ_VERSION': "{0} ({1})".format(__VERSION__, git_version)
'STOCKAZ_VERSION': "{0} ({1})".format(__VERSION__, git_version),
'STOCKAZ_PUBLIC': app.config['STOCKAZ_PUBLIC']
}
g.current_user = current_user


+ 1
- 0
templates/layout.jinja2 View File

@@ -96,6 +96,7 @@
<li><a href="{{ url_for('bp_views.view_infos') }}"><i class="fa fa-cogs fa-fw"></i> Informations</a></li>
<li><a href="{{ url_for('bp_views.view_storages') }}"><i class="fa fa-list-alt fa-fw"></i> Storage map</a></li>
<li><a href="{{ url_for('bp_views.parts_to_sold') }}"><i class="fa fa-money fa-fw"></i> Parts to sold</a></li>
<li><a href="{{ url_for('bp_views.parts_public') }}"><i class="fa fa-list-alt fa-fw"></i> Parts public</a></li>
</ul>
<!-- /.dropdown-user -->
</li>

+ 5
- 2
templates/parts/edit.jinja2 View File

@@ -65,8 +65,11 @@
{{ wtf.form_field(form.status, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{{ wtf.form_field(form.condition, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{{ wtf.form_field(form.needs_review, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{{ wtf.form_field(form.can_be_sold, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
</div>
{% if not g.cfg['STOCKAZ_PUBLIC'] %}
{{ wtf.form_field(form.can_be_sold, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{% else %}
{{ wtf.form_field(form.private, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{% endif %} </div>
</div>



+ 5
- 1
templates/parts/new.jinja2 View File

@@ -43,7 +43,11 @@
{{ wtf.form_field(form.condition, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{{ wtf.form_field(form.needs_review, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{{ wtf.form_field(form.add_new, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{{ wtf.form_field(form.can_be_sold, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{% if not g.cfg['STOCKAZ_PUBLIC'] %}
{{ wtf.form_field(form.can_be_sold, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{% else %}
{{ wtf.form_field(form.private, 'horizontal', horizontal_columns=('lg', 3, 9)) }}
{% endif %}
</div>
</div>


+ 68
- 0
templates/view/parts_public.jinja2 View File

@@ -0,0 +1,68 @@
{% extends "layout_empty.jinja2" %}

{% block content %}
<div class="row">
<div id="ContentTableParts">
{% include 'parts/_table.jinja2' %}
</div>
<div id="ContentPartSidebar"></div>
</div>
{% endblock %}

{% block scripts %}
<script>
$(document).ready(function () {
$('#TableParts').dataTable( {
"order": [],
"columnDefs": [ {
"targets" : 'no-sort',
"orderable": false
}]
});

$('#contentBody').on("click", ".del", function(){
var item = $(this);
var id = $(this).parent().parent().data().id;
var item_name = $(this).data().name;
if (!confirm("Are you sure to delete " + item_name + " ?")){
return false;
}

$.ajax({
url: '/parts/' + id + '/del',
type: 'DELETE',
success: function(result) {
item.parent().parent().remove()
}
});

return false;
}); // .del
}); // on document ready

function trigger_selected(ID, E, DATA) {
if (DATA.node) {
console.log("Selected Id: " + ID + " Text: " + DATA.node.text);
$("#ContentTableParts").load('/ajax/parts/from_category/' + ID, function() {
// load performed, now trigger DataTable on the new set
$('#TableParts').DataTable();
});
}
}

$('#contentBody').on("click", ".part_row", function() {
var row=$(this);

// make table col-lg-9
document.getElementById('ContentTableParts').className = "col-md-9 withSidebar";

// make sidebar col-lg-3
document.getElementById('ContentPartSidebar').className = "col-md-3 opened";

// load sidebar content
$('#ContentPartSidebar').load('/ajax/parts/'+ row.data().id +'/sidebar', function() {
//alert("ok");
});
}); // .part_row click
</script>
{% endblock %}