Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#38 add supplier parts view #93

Merged
merged 9 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bom/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ def wrap(request, *args, **kwargs):
wrap.__doc__ = function.__doc__
wrap.__name__ = function.__name__
return wrap

def organization_admin(function):
def wrap(request, *args, **kwargs):
if request.user.bom_profile().role != 'A':
messages.error(request, "You don't have permission to perform this action.")
return HttpResponseRedirect(request.META.get('HTTP_REFERER'), reverse('bom:home'))
return function(request, *args, **kwargs)

wrap.__doc__ = function.__doc__
wrap.__name__ = function.__name__
return wrap
6 changes: 6 additions & 0 deletions bom/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ def __init__(self, *args, **kwargs):
self.fields['mouser_disable'].initial = True


class SellerForm(forms.ModelForm):
class Meta:
model = Seller
exclude = ['organization', ]


class SellerPartForm(forms.ModelForm):
class Meta:
model = SellerPart
Expand Down
20 changes: 17 additions & 3 deletions bom/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
from bom.models import Part, PartClass, Seller, SellerPart, Subpart, \
Manufacturer, Organization, ManufacturerPart, PartRevision, Assembly, User, AssemblySubparts
from bom import constants
from bom.models import (
Assembly,
AssemblySubparts,
Manufacturer,
ManufacturerPart,
Organization,
Part,
PartClass,
PartRevision,
Seller,
SellerPart,
Subpart,
User,
)


def create_a_fake_organization(user, free=False, number_scheme=constants.NUMBER_SCHEME_SEMI_INTELLIGENT, number_variation_len=constants.NUMBER_VARIATION_LEN_DEFAULT):
Expand Down Expand Up @@ -154,8 +166,10 @@ def create_some_fake_parts(organization):
assy = create_a_fake_assembly()
pr1 = create_a_fake_part_revision(part=pt1, assembly=None)

mp2 = ManufacturerPart(part=pt2, manufacturer=None, manufacturer_part_number='GRM1555C1H100JA01D')
mp2 = ManufacturerPart(part=pt2, manufacturer=m2, manufacturer_part_number='GRM1555C1H100JA01D')
mp2.save()
mp22 = ManufacturerPart(part=pt2, manufacturer=None, manufacturer_part_number='ThisPartHasNoManufacturer')
mp22.save()
pt2.primary_manufacturer_part = mp2
pt2.save()
assy2 = create_a_fake_assembly_with_subpart(part_revision=pr1)
Expand Down
4 changes: 2 additions & 2 deletions bom/static/bom/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ td, tr {

/* Override treetable icon */
table.treetable tr.collapsed span.indenter a {
background-image: url('img/_ionicons_svg_md-arrow-dropright.svg');
background-image: url('../img/_ionicons_svg_md-arrow-dropright.svg');
}

table.treetable tr.expanded span.indenter a {
background-image: url('img/_ionicons_svg_md-arrow-dropdown.svg');
background-image: url('../img/_ionicons_svg_md-arrow-dropdown.svg');
}

/* Override Materialize container */
Expand Down
20 changes: 10 additions & 10 deletions bom/static/bom/css/treetable-theme.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bom/templates/bom/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ <h1 class="col s12 light header center">{{ title|safe }}</h1>
</div>
{% endif %}
{% if messages %}
<div id="content" class="container">
<div id="content" class="container">
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="card alert alert-{{ message.tags }} alert-dismissible"{% endif %} role="alert">
{{ message.message|safe }}
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% block content %}{% endblock %}
{% block action-btn %}{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions bom/templates/bom/bom-base-menu.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% if user.is_authenticated and user.bom_profile.organization %}
<li {% if name == "manufacturers" %}class="active"{% endif %}><a title="IndaBOM | Manufacturers" href="{% url 'bom:manufacturers' %}">Manufacturers</a></li>
<li {% if name == "sellers" %}class="active"{% endif %}><a title="IndaBOM | Sellers" href="{% url 'bom:sellers' %}">Sellers</a></li>
<li {% if name == "settings" %}class="active"{% endif %}><a title="IndaBOM | Settings" href="{% url 'bom:settings' tab_anchor='user' %}">Settings</a></li>
{% endif %}
<li {% if name == "help" %}class="active"{% endif %}><a title="IndaBOM | Help" href="{% url 'bom:help' %}">Help</a></li>
1 change: 1 addition & 0 deletions bom/templates/bom/bom-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<script>
$(document).ready(function () {
$('select').formSelect();
$('.sidenav').sidenav();
});
</script>
{% block bom-script %}{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'bom/css/treetable-theme.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'bom/css/jquery.treetable.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'bom/css/tablesorter-theme.materialize.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'bom/css/style.css' %}"/>
{% endblock %}

<div class="row printer-hide" style="padding-top: 16px;">
Expand Down
Loading