okcashpro/okshop

View on GitHub
shop/views.py

Summary

Maintainability
F
2 wks
Test Coverage

File views.py has 1044 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# vim: ai ts=4 sts=4 et sw=4
from django.shortcuts import render, get_object_or_404, redirect
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth import logout, authenticate, login
Severity: Major
Found in shop/views.py - About 2 days to fix

    Function edit_product has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring.
    Open

    def edit_product(request, id):
        product = get_object_or_404(Product, id=id, seller=request.user)
        shipping_countries = []
        for country in countries:
            shipping_countries.append({'country': country,
    Severity: Minor
    Found in shop/views.py - About 2 days to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function checkout has a Cognitive Complexity of 98 (exceeds 5 allowed). Consider refactoring.
    Open

    def checkout(request):
        if not hasattr(request.user, 'cart'):
            c = Cart(user=request.user)
            c.save()
        if request.user.cart.has_something_in_stock():
    Severity: Minor
    Found in shop/views.py - About 1 day to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function sell_new_product has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
    Open

    def sell_new_product(request):
        if request.method == 'POST':
            # Get ready for all the ifs!
            errors = []
    
    Severity: Minor
    Found in shop/views.py - About 1 day to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function login_view has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    def login_view(request):
        if request.method == 'POST':
            if 'username' in request.POST and 'password' in request.POST:
                username = request.POST['username']
                password = request.POST['password']
    Severity: Minor
    Found in shop/views.py - About 6 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function manage_keyset has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def manage_keyset(request, id, keyid=None):
        context = {}
    
        if keyid is not None:
            keyset = get_object_or_404(DigitalKeySet, id=keyid,
    Severity: Minor
    Found in shop/views.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function manage_order has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def manage_order(request, id):
        order = get_object_or_404(PurchaseItem, product__seller=request.user,
                                  id=id, product__physical=True)
    
        if request.method == 'POST':
    Severity: Minor
    Found in shop/views.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function change_password has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def change_password(request):
        if request.method == 'POST':
            errors = []
            curpass = request.POST.get('curpassword', '')
    
    Severity: Minor
    Found in shop/views.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function view_product has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def view_product(request, id):
        product = get_object_or_404(Product, id=id, approved=True)
    
    
        if request.method == 'POST':
    Severity: Minor
    Found in shop/views.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function editshop has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def editshop(request):
        if request.method == 'POST' and hasattr(request.user, 'usershop'):
            if 'description' in request.POST:
                request.user.usershop.description = request.POST['description']
            if 'css' in request.POST and request.user.usershop.can_customcss:
    Severity: Minor
    Found in shop/views.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function authorize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def authorize(request, forid):
        if request.method == 'POST' and 'password' in request.POST:
            u = authenticate(username=request.user.username,
                             password=request.POST.get('password', ''))
            if u is not None:
    Severity: Minor
    Found in shop/views.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function toggle_vote has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def toggle_vote(request, id, vote):
        review = get_object_or_404(Review, id=id)
    
        if ReviewVote.objects.filter(user=request.user, review=review).count():
            rv = ReviewVote.objects.get(user=request.user, review=review)
    Severity: Minor
    Found in shop/views.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function api_send has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def api_send(request):
        response = {}
        errors = []
        if request.method == 'POST' and 'wallet' in request.POST and \
                'address' in request.POST and \
    Severity: Minor
    Found in shop/views.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function api_checkaddress has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def api_checkaddress(request):
        response = {'status': ""}
        errors = []
        if 'address' in request.GET:
            validate = cm.validateaddress(request.GET['address'])
    Severity: Minor
    Found in shop/views.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function google_settings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def google_settings(request):
        args = {}
        if request.method == 'POST':
            if 'authcode' in request.POST and \
               request.user.userextra.authenticator_id:
    Severity: Minor
    Found in shop/views.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Consider simplifying this complex logical expression.
    Open

                if chkout.step == 0:
                    if request.POST.get('shipping', False) and \
                       request.user.physicaladdress_set \
                       .filter(id=request.POST.get('shipping', 0)).count() >= 1:
                        chkout.shipping = request.user.physicaladdress_set.get(
    Severity: Major
    Found in shop/views.py - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

                      if request.POST.get('shipping', False) and \
                         request.user.physicaladdress_set \
                         .filter(id=request.POST.get('shipping', 0)).count() >= 1:
                          chkout.shipping = request.user.physicaladdress_set.get(
                              id=request.POST.get('shipping', 0))
      Severity: Major
      Found in shop/views.py - About 1 hr to fix

        Function upload_file_noapi has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def upload_file_noapi(request, id):
            product = get_object_or_404(Product, id=id, physical=False,
                                        seller=request.user)
            if 'file' in request.FILES and \
               0 < len(request.POST.get('name', '')) <= 200:
        Severity: Minor
        Found in shop/views.py - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function add_to_cart has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def add_to_cart(request, id):
            cart = request.user.cart
            product = get_object_or_404(Product, id=id, approved=True, removed=False)
            if request.user.userextra.can_purchase_item(product):
                if product.in_stock():
        Severity: Minor
        Found in shop/views.py - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Avoid deeply nested control flow statements.
        Open

                            if chkout.step <= 1 and len(addresses) > 0:
                                chkout.step = 1
                            else:
                                messages.warning(request, "Not enough balance!")
                                return redirect("shop:cart")
        Severity: Major
        Found in shop/views.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if p.product is None:
                                      p.product = product
                                      p.save()
                              except ObjectDoesNotExist:
          Severity: Major
          Found in shop/views.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if i.uuid not in request.POST.getlist('images', []):
                                    i.delete()
                        else:
            Severity: Major
            Found in shop/views.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  for item in chkout.cart.cartentry_set.all():
                                      t = False
                                      if not item.product.ships_to(chkout.shipping):
                                          messages.warning(
                                              request,
              Severity: Major
              Found in shop/views.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if country not in dict(countries):
                                        errors.append('%s is not a country!' % country)
                                    else:
                                        sc = ShippingCountry(product=product, country=country)
                                        sc.save()
                Severity: Major
                Found in shop/views.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if country not in dict(countries):
                                          errors.append('%s is not a country!' % country)
                              if 'free-shipping' in request.POST:
                  Severity: Major
                  Found in shop/views.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if country in dict(countries):
                                            c = ShippingCountry(country=country, product=p)
                                            c.save()
                                p.save()
                    Severity: Major
                    Found in shop/views.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if 0 < len(request.POST['zip'].strip()) <= 15 and\
                                                  0 < len(request.POST['name'].strip()) <= 200 and\
                                                  request.POST['address1'].strip() != '' and\
                                                  request.POST['country'].strip() in dict(countries)\
                                                  and request.POST['state'].strip() != '':
                      Severity: Major
                      Found in shop/views.py - About 45 mins to fix

                        Function register_view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def register_view(request):
                            if request.method == 'POST':
                                form = RegisterForm(request.POST)
                                if form.is_valid():
                                    messages.success(request,
                        Severity: Minor
                        Found in shop/views.py - About 45 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Avoid deeply nested control flow statements.
                        Open

                                            if chkout.get_price() == Decimal(0) and\
                                             len(addresses) == 0:
                                                a = Wallet(user=request.user, label='default')
                                                a.save()
                                                chkout.wallet = a
                        Severity: Major
                        Found in shop/views.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if user.userextra.verify_2fa(
                                                      request.POST.get('2facode', '')):
                                                  login(request, user)
                                                  messages.success(request,
                                                                   "Welcome back, %s!" % user.username)
                          Severity: Major
                          Found in shop/views.py - About 45 mins to fix

                            Function upload_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def upload_file(request, id):
                                product = get_object_or_404(Product, id=id, physical=False)
                                if product.seller != request.user:
                                    e = {
                                        'status': 403,
                            Severity: Minor
                            Found in shop/views.py - About 35 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function shop has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def shop(request, user):
                                try:
                                    usershop = get_object_or_404(UserShop, user__username=user)
                                except Http404:
                                    if User.objects.filter(username=user).count() > 0:
                            Severity: Minor
                            Found in shop/views.py - About 35 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Avoid too many return statements within this function.
                            Open

                                    return redirect('shop:cart')
                            Severity: Major
                            Found in shop/views.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return render(request, 'shop/checkout3.html', {'checkout': chkout})
                              Severity: Major
                              Found in shop/views.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return render(request, 'shop/checkout2.html',
                                Severity: Major
                                Found in shop/views.py - About 30 mins to fix

                                  Function get_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  def get_key(request):
                                      if request.method == 'POST' and 'purchaseid' in request.POST and \
                                         'keyid' in request.POST:
                                          try:
                                              purchase = PurchaseItem.objects.get(purchase__by=request.user,
                                  Severity: Minor
                                  Found in shop/views.py - About 25 mins to fix

                                  Cognitive Complexity

                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                  A method's cognitive complexity is based on a few simple rules:

                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                  • Code is considered more complex for each "break in the linear flow of the code"
                                  • Code is considered more complex when "flow breaking structures are nested"

                                  Further reading

                                  Function api_newwallet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  def api_newwallet(request):
                                      response = {'status': ""}
                                      errors = []
                                      if request.method == 'POST' and 'wallet_name' in request.POST:
                                          if len(request.POST['wallet_name']) > 30:
                                  Severity: Minor
                                  Found in shop/views.py - About 25 mins to fix

                                  Cognitive Complexity

                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                  A method's cognitive complexity is based on a few simple rules:

                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                  • Code is considered more complex for each "break in the linear flow of the code"
                                  • Code is considered more complex when "flow breaking structures are nested"

                                  Further reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                                  try:
                                                      local_shipping = Decimal(
                                                          request.POST.get('local-price', 0))
                                                      if local_shipping < 0:
                                                          errors.append(
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 3 hrs to fix
                                  shop/views.py on lines 1006..1015

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 63.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                                  try:
                                                      global_shipping = Decimal(request.POST.get('global-price',
                                                                                                 0))
                                                      if global_shipping < 0:
                                                          errors.append(
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 3 hrs to fix
                                  shop/views.py on lines 996..1005

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 63.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                          if rv.up == (vote == 'up'):
                                              if 'next' in request.GET and request.GET['next'] != '':
                                                  return redirect(request.GET['next'])
                                              else:
                                                  return redirect(review.product)
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 2 hrs to fix
                                  shop/views.py on lines 1158..1161

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 56.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                      if 'next' in request.GET and request.GET['next'] != '':
                                          return redirect(request.GET['next'])
                                      else:
                                          return redirect(review.product)
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 2 hrs to fix
                                  shop/views.py on lines 1145..1149

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 56.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 4 locations. Consider refactoring.
                                  Open

                                                          if 'next' in request.GET and request.GET['next'] != '':
                                                              return redirect(request.GET['next'])
                                                          else:
                                                              return redirect('/')
                                  Severity: Major
                                  Found in shop/views.py and 3 other locations - About 2 hrs to fix
                                  shop/views.py on lines 138..141
                                  shop/views.py on lines 208..211
                                  shop/views.py on lines 222..225

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 54.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 4 locations. Consider refactoring.
                                  Open

                                      if 'next' in request.GET and request.GET['next'] != '':
                                          return redirect(request.GET['next'])
                                      else:
                                          return redirect('/')
                                  Severity: Major
                                  Found in shop/views.py and 3 other locations - About 2 hrs to fix
                                  shop/views.py on lines 138..141
                                  shop/views.py on lines 169..172
                                  shop/views.py on lines 208..211

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 54.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 4 locations. Consider refactoring.
                                  Open

                                              if 'next' in request.GET and request.GET['next'] != '':
                                                  return redirect(request.GET['next'])
                                              else:
                                                  return redirect('shop:login')
                                  Severity: Major
                                  Found in shop/views.py and 3 other locations - About 2 hrs to fix
                                  shop/views.py on lines 138..141
                                  shop/views.py on lines 169..172
                                  shop/views.py on lines 222..225

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 54.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 4 locations. Consider refactoring.
                                  Open

                                      if 'next' in request.GET and request.GET['next'] != '':
                                          return redirect(request.GET['next'])
                                      else:
                                          return redirect('shop:cart')
                                  Severity: Major
                                  Found in shop/views.py and 3 other locations - About 2 hrs to fix
                                  shop/views.py on lines 169..172
                                  shop/views.py on lines 208..211
                                  shop/views.py on lines 222..225

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 54.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                          try:
                                              price = Decimal(request.POST.get('price', 0))
                                              if price < 0:
                                                  errors.append('Price has to be at least 0')
                                              else:
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 2 hrs to fix
                                  shop/views.py on lines 953..959

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 53.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 4 locations. Consider refactoring.
                                  Open

                                          if 'unlimited' not in request.POST:
                                              try:
                                                  stock = int(request.POST.get('stock', 0))
                                                  if stock < 0:
                                                      errors.append('Stock has to be at least 0')
                                  Severity: Major
                                  Found in shop/views.py and 3 other locations - About 2 hrs to fix
                                  shop/views.py on lines 787..792
                                  shop/views.py on lines 807..814
                                  shop/views.py on lines 815..822

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 53.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 4 locations. Consider refactoring.
                                  Open

                                                  try:
                                                      global_shipping = Decimal(
                                                          request.POST.get('global-price', 0))
                                                      if global_shipping < 0:
                                                          errors.append(
                                  Severity: Major
                                  Found in shop/views.py and 3 other locations - About 2 hrs to fix
                                  shop/views.py on lines 780..786
                                  shop/views.py on lines 787..792
                                  shop/views.py on lines 807..814

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 53.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 4 locations. Consider refactoring.
                                  Open

                                          try:
                                              price = Decimal(request.POST.get('price', 0))
                                              if price < 0:
                                                  errors.append('Price has to be at least 0')
                                          except ValueError:
                                  Severity: Major
                                  Found in shop/views.py and 3 other locations - About 2 hrs to fix
                                  shop/views.py on lines 780..786
                                  shop/views.py on lines 807..814
                                  shop/views.py on lines 815..822

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 53.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 4 locations. Consider refactoring.
                                  Open

                                                  try:
                                                      local_shipping = Decimal(
                                                          request.POST.get('local-price', 0))
                                                      if local_shipping < 0:
                                                          errors.append(
                                  Severity: Major
                                  Found in shop/views.py and 3 other locations - About 2 hrs to fix
                                  shop/views.py on lines 780..786
                                  shop/views.py on lines 787..792
                                  shop/views.py on lines 815..822

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 53.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                          try:
                                              stock = int(request.POST.get('stock', 0))
                                              if stock < 0:
                                                  errors.append('Stock has to be at least 0')
                                              else:
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 2 hrs to fix
                                  shop/views.py on lines 961..967

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 53.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                      doneorders = PurchaseItem.objects.all()\
                                          .annotate(done=models.Count(models.Case(
                                              models.When(shippingupdate__done=True, then=1),
                                              output_field=models.CharField())))\
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/views.py on lines 653..656

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 48.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                      inproggress = PurchaseItem.objects.all()\
                                          .annotate(done=models.Count(models.Case(
                                              models.When(shippingupdate__done=True, then=1),
                                              output_field=models.CharField())))\
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/views.py on lines 659..662

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 48.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                      if len(errors) > 0:
                                          response['status'] = 'error'
                                          response['errors'] = errors
                                      else:
                                          response['status'] = 'success'
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/models.py on lines 430..434

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 48.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                  @login_required
                                  def keys(request):
                                      digital_purchases = PurchaseItem.objects.filter(purchase__by=request.user,
                                                                                      product__physical=False)\
                                                                                  .order_by('-purchase__date')
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/views.py on lines 611..616

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 47.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                  @login_required
                                  def orders(request):
                                      order_list = PurchaseItem.objects.filter(purchase__by=request.user,
                                                                               product__physical=True)\
                                                                               .order_by('-purchase__date')
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/views.py on lines 511..516

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 47.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                              f = DigitalFile(product=product, file=request.FILES['file'],
                                                              name=request.POST.get('name', ''),
                                                              description=request.POST.get('description', ''))
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/views.py on lines 1073..1075

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 46.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                                  if request.POST.get('address', False) and \
                                                   request.user.wallet_set.filter(id=request.POST.get('address',
                                                                                                      0)) \
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/views.py on lines 372..374

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 46.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                              f = DigitalFile(product=product, file=request.FILES['file'],
                                                              name=request.POST.get('name', ''),
                                                              description=request.POST.get('description', ''))
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/views.py on lines 1101..1103

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 46.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                                  if request.POST.get('shipping', False) and \
                                                     request.user.physicaladdress_set \
                                                     .filter(id=request.POST.get('shipping', 0)).count() >= 1:
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/views.py on lines 421..423

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 46.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                                  if not u.done:
                                                      send_mail("Update on one of your orders", """Hello %s,
                                  
                                  There's a new update for your order of %d %s.
                                  
                                  Severity: Major
                                  Found in shop/views.py and 1 other location - About 1 hr to fix
                                  shop/views.py on lines 691..716

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 44.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                      if 'file' in request.FILES and \
                                         0 < len(request.POST.get('name', '')) <= 200:
                                  Severity: Minor
                                  Found in shop/views.py and 1 other location - About 45 mins to fix
                                  shop/views.py on lines 1070..1071

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 35.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                          if not hasattr(verify.user, 'userextra'):
                                              ue = UserExtra(user=verify.user)
                                              ue.save()
                                  Severity: Minor
                                  Found in shop/views.py and 1 other location - About 45 mins to fix
                                  shop/views.py on lines 362..364

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 35.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                      if 'file' in request.FILES and\
                                         0 < len(request.POST.get('name', '')) <= 200:
                                  Severity: Minor
                                  Found in shop/views.py and 1 other location - About 45 mins to fix
                                  shop/views.py on lines 1098..1099

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 35.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                      if not hasattr(request.user, 'cart'):
                                          c = Cart(user=request.user)
                                          c.save()
                                  Severity: Minor
                                  Found in shop/views.py and 1 other location - About 45 mins to fix
                                  shop/views.py on lines 232..234

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 35.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  There are no issues that match your filters.

                                  Category
                                  Status