Code Duplication    Length = 22-24 lines in 2 locations

web/opensubmit/views.py 2 locations

@@ 378-401 (lines=24) @@
375
        raise PermissionDenied(
376
            "Withdrawal for this assignment is no longer possible, or you are unauthorized to access that submission.")
377
    if "confirm" in request.POST:
378
        submission.state = Submission.WITHDRAWN
379
        submission.save()
380
        messages.info(request, 'Submission successfully withdrawn.')
381
        return redirect('dashboard')
382
    else:
383
        return render(request, 'withdraw.html', {'submission': submission})
384
385
386
@lti_provider(consumer_lookup=lti_secret, site_url=MAIN_URL)
387
@require_POST
388
def lti(request, post_params, consumer_key, *args, **kwargs):
389
    '''
390
        Entry point for LTI consumers.
391
392
        This view is protected by the BLTI package decorator,
393
        which performs all the relevant OAuth signature checking.
394
        It also makes sure that the LTI consumer key and secret were ok.
395
        The latter ones are supposed to be configured in the admin interface.
396
397
        We can now trust on the provided data to be from the LTI provider.
398
399
        If everything worked out, we store the information the session for
400
        the Python Social passthrough provider, which is performing
401
        user creation and database storage.
402
    '''
403
    data = {}
404
    data['ltikey'] = post_params.get('oauth_consumer_key')
@@ 404-425 (lines=22) @@
401
        user creation and database storage.
402
    '''
403
    data = {}
404
    data['ltikey'] = post_params.get('oauth_consumer_key')
405
    # None of them is mandatory
406
    data['id'] = post_params.get('user_id', None)
407
    data['username'] = post_params.get('custom_username', None)
408
    data['last_name'] = post_params.get('lis_person_name_family', None)
409
    data['email'] = post_params.get('lis_person_contact_email_primary', None)
410
    data['first_name'] = post_params.get('lis_person_name_given', None)
411
    request.session[passthrough.SESSION_VAR] = data
412
    return redirect(reverse('social:begin', args=['lti']))
413