{"action":"created","issue":{"url":"https://api.github.com/repos/mitodl/micromasters/issues/2448","repository_url":"https://api.github.com/repos/mitodl/micromasters","labels_url":"https://api.github.com/repos/mitodl/micromasters/issues/2448/labels{/name}","comments_url":"https://api.github.com/repos/mitodl/micromasters/issues/2448/comments","events_url":"https://api.github.com/repos/mitodl/micromasters/issues/2448/events","html_url":"https://github.com/mitodl/micromasters/pull/2448","id":203619249,"number":2448,"title":"Fixed exam authorization command and refactoring","user":{"login":"amir-qayyum-khan","id":10431250,"avatar_url":"https://avatars.githubusercontent.com/u/10431250?v=3","gravatar_id":"","url":"https://api.github.com/users/amir-qayyum-khan","html_url":"https://github.com/amir-qayyum-khan","followers_url":"https://api.github.com/users/amir-qayyum-khan/followers","following_url":"https://api.github.com/users/amir-qayyum-khan/following{/other_user}","gists_url":"https://api.github.com/users/amir-qayyum-khan/gists{/gist_id}","starred_url":"https://api.github.com/users/amir-qayyum-khan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amir-qayyum-khan/subscriptions","organizations_url":"https://api.github.com/users/amir-qayyum-khan/orgs","repos_url":"https://api.github.com/users/amir-qayyum-khan/repos","events_url":"https://api.github.com/users/amir-qayyum-khan/events{/privacy}","received_events_url":"https://api.github.com/users/amir-qayyum-khan/received_events","type":"User","site_admin":false},"labels":[{"id":335628406,"url":"https://api.github.com/repos/mitodl/micromasters/labels/Waiting%20on%20Author","name":"Waiting on Author","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":{"login":"giocalitri","id":1005204,"avatar_url":"https://avatars.githubusercontent.com/u/1005204?v=3","gravatar_id":"","url":"https://api.github.com/users/giocalitri","html_url":"https://github.com/giocalitri","followers_url":"https://api.github.com/users/giocalitri/followers","following_url":"https://api.github.com/users/giocalitri/following{/other_user}","gists_url":"https://api.github.com/users/giocalitri/gists{/gist_id}","starred_url":"https://api.github.com/users/giocalitri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giocalitri/subscriptions","organizations_url":"https://api.github.com/users/giocalitri/orgs","repos_url":"https://api.github.com/users/giocalitri/repos","events_url":"https://api.github.com/users/giocalitri/events{/privacy}","received_events_url":"https://api.github.com/users/giocalitri/received_events","type":"User","site_admin":false},"assignees":[{"login":"giocalitri","id":1005204,"avatar_url":"https://avatars.githubusercontent.com/u/1005204?v=3","gravatar_id":"","url":"https://api.github.com/users/giocalitri","html_url":"https://github.com/giocalitri","followers_url":"https://api.github.com/users/giocalitri/followers","following_url":"https://api.github.com/users/giocalitri/following{/other_user}","gists_url":"https://api.github.com/users/giocalitri/gists{/gist_id}","starred_url":"https://api.github.com/users/giocalitri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giocalitri/subscriptions","organizations_url":"https://api.github.com/users/giocalitri/orgs","repos_url":"https://api.github.com/users/giocalitri/repos","events_url":"https://api.github.com/users/giocalitri/events{/privacy}","received_events_url":"https://api.github.com/users/giocalitri/received_events","type":"User","site_admin":false}],"milestone":null,"comments":18,"created_at":"2017-01-27T12:01:53Z","updated_at":"2017-02-09T17:21:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mitodl/micromasters/pulls/2448","html_url":"https://github.com/mitodl/micromasters/pull/2448","diff_url":"https://github.com/mitodl/micromasters/pull/2448.diff","patch_url":"https://github.com/mitodl/micromasters/pull/2448.patch"},"body":"#### What are the relevant tickets?\r\n- fixes https://github.com/mitodl/micromasters/issues/2445\r\n- Fixed ripples of #2331\r\n\r\n#### What's this PR do?\r\n- Refactored the code of exam authorization command\r\n- Added exceptions and logging to see behaviour of code\r\n- Added new tests for authorization code.\r\n\r\n### How to test:\r\n- In .env add `FEATURE_FINAL_GRADE_ALGORITHM=v1`\r\n- Set program.exam_series_code\r\n- Set course.exam_module\r\n- Pay for course\r\n- Create final grade http://192.168.99.100:8079/admin/grades/finalgrade/\r\n- Run command ```docker-compose run web ./manage.py authorization_user_exam --username=(value) --program-id=(value)```\r\n- Check weather ( ExamAuthoriztion) object created \r\n  - ``docker-compose run web ./manage.py shell``\r\n  - ``from exams.models import ExamAuthorization``\r\n  -  ``ExamAuthorization.objects.all()``\r\n\r\n#### To create dummy data:\r\n```docker-compose run web ./manage.py shell```\r\n\r\n```shell\r\nfrom courses.models import CourseRun\r\nfrom dashboard.models import CachedEnrollment\r\nfrom dashboard.factories import CachedEnrollmentFactory\r\nfrom ecommerce.factories import (OrderFactory, LineFactory)\r\nfrom django.contrib.auth.models import User\r\nfrom exams.models import ExamAuthorization\r\n\r\nuser = User.objects.get(username='amirq')\r\n# use same  `edx_course_key` for final grade entry\r\ncourse_run = CourseRun.objects.get(edx_course_key='course-v1:MITx+Digital+Learning+100+Jan_2016')\r\nCachedEnrollmentFactory.create(user=user, course_run=course_run)\r\n# enter  `total_price_paid` according to income threshold\r\norder = OrderFactory.create(user=user, status='fulfilled', total_price_paid=1200)\r\nLineFactory.create(order=order, course_key=course_run.edx_course_key)\r\nExamAuthorization.objects.all()\r\n```\r\n\r\n@pdpinch @giocalitri "},"comment":{"url":"https://api.github.com/repos/mitodl/micromasters/issues/comments/278710484","html_url":"https://github.com/mitodl/micromasters/pull/2448#issuecomment-278710484","issue_url":"https://api.github.com/repos/mitodl/micromasters/issues/2448","id":278710484,"user":{"login":"amir-qayyum-khan","id":10431250,"avatar_url":"https://avatars.githubusercontent.com/u/10431250?v=3","gravatar_id":"","url":"https://api.github.com/users/amir-qayyum-khan","html_url":"https://github.com/amir-qayyum-khan","followers_url":"https://api.github.com/users/amir-qayyum-khan/followers","following_url":"https://api.github.com/users/amir-qayyum-khan/following{/other_user}","gists_url":"https://api.github.com/users/amir-qayyum-khan/gists{/gist_id}","starred_url":"https://api.github.com/users/amir-qayyum-khan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amir-qayyum-khan/subscriptions","organizations_url":"https://api.github.com/users/amir-qayyum-khan/orgs","repos_url":"https://api.github.com/users/amir-qayyum-khan/repos","events_url":"https://api.github.com/users/amir-qayyum-khan/events{/privacy}","received_events_url":"https://api.github.com/users/amir-qayyum-khan/received_events","type":"User","site_admin":false},"created_at":"2017-02-09T17:21:32Z","updated_at":"2017-02-09T17:21:32Z","body":"Done @giocalitri https://github.com/mitodl/micromasters/issues/2535"}}
{"actor":{"display_login":"amir-qayyum-khan"}}