Exemplo n.º 1
0
def test_human():
    """
    Final human sanity check.
    """
    human_approves = confirm("Does that look OK for you?")
    if not human_approves:
        f.error("Cancelled by user.")
Exemplo n.º 2
0
def test_external():
    """
    Runs tests against known sites. Only exits on catastrophic failure.
    """
    external_passed = _scan_external()
    if not external_passed:
        f.error("External scans failed... abort.")
Exemplo n.º 3
0
def test_internal():
    """
    Runs unit tests.
    """
    tests_passed = subprocess.call(['../droopescan', 'test']) == 0
    if not tests_passed:
        f.error("Unit tests failed... abort.")
Exemplo n.º 4
0
def products(request, company):
    c = get_object_or_404(Company, url_name=company)
    
    # needs to be at least guest to view products
    if not has_permission(request.user, c, 'product', 'view'):
        return no_permission_view(request, c, _("You have no permission to view products."))

    # if there are no taxes defined, don't show anything
    if Tax.objects.filter(company=c).count() == 0:
        return error(request, c, _("There are no taxes defined. Please go to tax management and define them."))

    # if there are no categories defined, throw an error
    if Category.objects.filter(company=c).count() == 0:
        return error(request, c, _("There are no categories defined, please go to category management to define them."))

    # fields that need to be limited in length:
    lengths = {
        'code': max_field_length(Product, 'code'),
        'price': g.DECIMAL['currency_digits'] + 1,
        'purchase_price': g.DECIMAL['currency_digits'] + 1,
        'shortcut': max_field_length(Product, 'shortcut'),
        'stock': g.DECIMAL['quantity_digits'],
        'name': max_field_length(Product, 'name'),
        'tax': g.DECIMAL['percentage_decimal_places'] + 4,  # up to '100.' + 'decimal_digits'
    }
    
    context = {
        'company': c,
        'title': _("Products"),
        'site_title': g.MISC['site_title'],
        # lists
        'taxes': JsonStringify(get_all_taxes(request.user, c)),
        'categories': JsonStringify(get_all_categories(c, json=True)),
        'units': JsonStringify(g.UNITS),
        'discounts': JsonStringify(get_all_discounts(request.user, c)),
        # urls for ajax calls
        'add_url': reverse('pos:create_product', args=[c.url_name]),
        # config variables
        'can_edit': has_permission(request.user, c, 'product', 'edit'),
        'currency': get_company_value(request.user, c, 'pos_currency'),
        # images
        'image_dimensions': g.IMAGE_DIMENSIONS['product'],
        'image_upload_formats': g.MISC['image_upload_formats'], # what can be uploaded
        'max_upload_size': round(g.MISC['max_upload_image_size']/2**20, 2), # show in megabytes
        'max_upload_size_bytes': g.MISC['max_upload_image_size'], # bytes for javascript
        # html fields
        'field_lengths': lengths,
        'separator': get_company_value(request.user, c, 'pos_decimal_separator'),
        # numbers etc
        'default_tax_id': get_default_tax(request.user, c)['id'],
        'decimal_places': get_company_value(request.user, c, 'pos_decimal_places')*2,  # ACHTUNG: rounding comes at the end
    }
    return render(request, 'pos/manage/products.html', context)
Exemplo n.º 5
0
def changelog_modify():
    prev_version_nb = read_first_line(CHANGELOG)
    version_nb = get_input("Version number (prev %s):" %
            prev_version_nb)

    final = changelog(version_nb).strip() + "\n\n"

    print("The following will be prepended to the CHANGELOG:\n---\n%s---" % final)

    ok = confirm("Is that OK?")
    if ok:
        prepend_to_file(CHANGELOG, final)
        return version_nb
    else:
        f.error("Cancelled by user.")
Exemplo n.º 6
0
def check_pypirc():
    pypirc = os.path.expanduser("~/.pypirc")
    if not os.path.isfile(pypirc):
        f.error('File "%s" does not exist.' % pypirc)