Esempio n. 1
0
 def test_project_branches(self):
     """Test getting project branches"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'commit': {
             'branch': 'master',
         }
     }, {
         'project': project.name,
         'commit': {
             'branch': 'develop',
         }
     }, {
         'project': project.name,
         'commit': {
             'branch': 'master',
         }
     }, {
         'project': project.name,
         'commit': {
             'branch': 'develop',
         }
     }])
     set(project.branches).should.be.equal({'master', 'develop'})
Esempio n. 2
0
def travis_ci_service(data):
    """Create tasks from data received from travis-c

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId or None -- pk of created task
    """
    try:
        assert Tasks.find({
            'service.name': 'travis_ci',
            'service.job_id': data['service']['job_id'],
        }).count() <= 1

        job = requests.get(
            'https://api.travis-ci.org/jobs/{}'.format(
                data['service']['job_id'], ), ).json()

        repo = requests.get(
            'https://api.travis-ci.org/repos/{}'.format(
                job['repository_id'], ), ).json()

        # TODO: add pull request support
        assert data['project'] == repo['slug']

        if data['service'].get('pull_request_id'):
            pull_request = data['service']['pull_request_id']
            if pull_request != 'false':
                data['pull_request_id'] = int(
                    data['service']['pull_request_id'], )

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Travis-ci service fail: {}'.format(e))
Esempio n. 3
0
    def get_context_data(self, **kwargs):
        """Get day statistic"""
        success = Tasks.find({
            'created': {
                '$gte': datetime.now() - timedelta(days=1)
            },
            'status': STATUS_SUCCESS
        }).count()

        failed = Tasks.find({
            'created': {
                '$gte': datetime.now() - timedelta(days=1)
            },
            'status': STATUS_FAILED
        }).count()

        if failed:
            failed_percent = failed * 100 / (success + failed)
        else:
            failed_percent = 0

        return {
            'failed': failed_percent,
            'success': 100 - failed_percent,
            'debug': settings.DEBUG,
            'site': Site.objects.get_current(),
        }
 def test_update_quality_game_with_new_violation(self):
     """Test update quality game with new violation"""
     project = factories.ProjectFactory()
     Tasks.save({
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() - timedelta(hours=5),
         'commit': {
             'branch': 'test',
             'author': 'test',
             'inner': [{'author': {'url': 'test'}}]
         },
         'violations': [],
     })
     project.update_quality_game({
         'project': project.name,
         'success_percent': 15,
         'status': STATUS_SUCCESS,
         'created': datetime.now(),
         'commit': {
             'branch': 'test',
             'author': 'test',
             'inner': [{'author': {'url': 'test'}}]
         },
         'violations': [
             {'name': 'cat', 'success_percent': 15},
         ],
     })
     project.quality_game['violations']['cat']['test']['value']\
         .should.be.equal(1)
 def test_fail_on_travis_api_error(self):
     """Test fail on travis api error"""
     travis_ci.requests.get.side_effect = Exception
     data = self._create_task()
     with LogCapture() as log_capture:
         travis_ci.travis_ci_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(0)
 def test_fail_if_already_exists(self):
     """Test fail if job already exists"""
     self._create_task()
     data = self._create_task()
     with LogCapture() as log_capture:
         travis_ci.travis_ci_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(1)
 def test_fail_if_already_exists(self):
     """Test fail if job already exists"""
     self._create_task()
     data = self._create_task()
     with LogCapture() as log_capture:
         travis_ci.travis_ci_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(1)
 def test_fail_on_travis_api_error(self):
     """Test fail on travis api error"""
     travis_ci.requests.get.side_effect = Exception
     data = self._create_task()
     with LogCapture() as log_capture:
         travis_ci.travis_ci_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(0)
Esempio n. 9
0
 def test_success(self):
     """Test redirect to success badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'success')
Esempio n. 10
0
 def test_fail(self):
     """Test redirect to fail badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_FAILED,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'fail')
Esempio n. 11
0
 def test_fail(self):
     """Test redirect to fail badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_FAILED,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'fail')
Esempio n. 12
0
 def test_get_success_percents(self):
     """Test get success percents"""
     project = factories.ProjectFactory()
     Tasks.save({
         'project': project.name,
         'commit': {'branch': 'branch'},
         'success_percent': 92,
     })
     project.get_success_percents(10).should.be.equal([92])
Esempio n. 13
0
 def test_get_badge_with_filtering(self):
     """Test get badge with filtering"""
     project = factories.ProjectFactory.create()
     Tasks.save({
         'status': const.STATUS_SUCCESS,
         'project': project.name,
         'commit': {'branch': 'test'}
     })
     self._get_and_assert(project.name, 'success', '?branch=test')
Esempio n. 14
0
 def test_success(self):
     """Test redirect to success badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'success')
Esempio n. 15
0
 def test_get_neutral_trend(self):
     """Test get neutral trend"""
     project = factories.ProjectFactory()
     Tasks.save({
         'project': project.name,
         'commit': {'branch': 'branch'},
         'success_percent': 0,
     })
     project.get_trend().should.be.equal(0)
Esempio n. 16
0
 def test_get_negative_trend(self):
     """Test get negative trend"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'commit': {'branch': 'branch'},
         'success_percent': n,
         'created': num,
     } for num, n in enumerate(range(5, 1, -1))])
     project.get_trend().should.be.lower_than(0)
 def _create_task(self):
     """Create task"""
     task_id = Tasks.save({
         'project': 'test',
         'service': {
             'name': 'travis_ci',
             'job_id': 15,
         }
     })
     return Tasks.find_one(task_id)
 def _create_task(self):
     """Create task"""
     task_id = Tasks.save({
         'project': 'test',
         'service': {
             'name': 'travis_ci',
             'job_id': 15,
         }
     })
     return Tasks.find_one(task_id)
Esempio n. 19
0
 def test_success(self):
     """Test success"""
     task_id = Tasks.save({
         'project': 'test',
         'service': {
             'name': 'token',
             'token': self.project.token,
         }
     })
     data = Tasks.find_one(task_id)
     task_id.should.be.equal(token_service(data))
Esempio n. 20
0
 def test_update_day_time_statistic(self):
     """Test update day time statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(hours=4 * part),
     } for part in range(6)])
     project.update_day_time_statistic()
     len(project.day_time_statistic).should.be.ok
Esempio n. 21
0
 def test_update_week_statistic(self):
     """Test update week statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(days=day),
     } for day in range(7)])
     project.update_week_statistic()
     len(project.week_statistic).should.be.ok
Esempio n. 22
0
 def test_get_neutral_trend(self):
     """Test get neutral trend"""
     project = factories.ProjectFactory()
     Tasks.save({
         'project': project.name,
         'commit': {
             'branch': 'branch'
         },
         'success_percent': 0,
     })
     project.get_trend().should.be.equal(0)
Esempio n. 23
0
 def test_get_success_percents(self):
     """Test get success percents"""
     project = factories.ProjectFactory()
     Tasks.save({
         'project': project.name,
         'commit': {
             'branch': 'branch'
         },
         'success_percent': 92,
     })
     project.get_success_percents(10).should.be.equal([92])
Esempio n. 24
0
def create_task(request):
    user = request.user
    response = Response(data={'status': 'error'}, status=status.HTTP_200_OK)
    request_data = json.loads(request.body)
    if request_data.get('title') and request_data.get('description'):
        task = Tasks(title=request_data.get('title'),
                     description=request_data.get('description'),
                     owner=user)
        task.save()
        response.data = {'status': 'success'}
    return response
Esempio n. 25
0
 def test_update_week_statistic(self):
     """Test update week statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(days=day),
     } for day in range(7)])
     project.update_week_statistic()
     len(project.week_statistic).should.be.ok
Esempio n. 26
0
 def test_get_badge_with_filtering(self):
     """Test get badge with filtering"""
     project = factories.ProjectFactory.create()
     Tasks.save({
         'status': const.STATUS_SUCCESS,
         'project': project.name,
         'commit': {
             'branch': 'test'
         }
     })
     self._get_and_assert(project.name, 'success', '?branch=test')
Esempio n. 27
0
 def test_update_day_time_statistic(self):
     """Test update day time statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(hours=4 * part),
     } for part in range(6)])
     project.update_day_time_statistic()
     len(project.day_time_statistic).should.be.ok
 def test_fail_on_wrong_project(self):
     """Test fail on wrong project"""
     travis_ci.requests.get.return_value = MagicMock(json=MagicMock(
         return_value={
             'repository_id': 2,
             'slug': 'wrong',
         }))
     data = self._create_task()
     with LogCapture() as log_capture:
         travis_ci.travis_ci_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(0)
Esempio n. 29
0
 def test_get_negative_trend(self):
     """Test get negative trend"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'commit': {
             'branch': 'branch'
         },
         'success_percent': n,
         'created': num,
     } for num, n in enumerate(range(5, 1, -1))])
     project.get_trend().should.be.lower_than(0)
Esempio n. 30
0
 def test_unknown_because_last_task_not_finished(self):
     """Test unknown because not tasks performed"""
     project = factories.ProjectFactory.create()
     Tasks.insert([{
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     }, {
         'created': datetime(2011, 11, 11),
         'status': const.STATUS_NEW,
         'project': project.name,
     }])
     self._get_and_assert(project.name, 'unknown')
 def test_fail_on_wrong_project(self):
     """Test fail on wrong project"""
     travis_ci.requests.get.return_value = MagicMock(
         json=MagicMock(return_value={
             'repository_id': 2,
             'slug': 'wrong',
         })
     )
     data = self._create_task()
     with LogCapture() as log_capture:
         travis_ci.travis_ci_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(0)
Esempio n. 32
0
 def test_project_branches(self):
     """Test getting project branches"""
     project = factories.ProjectFactory()
     Tasks.insert([{'project': project.name, 'commit': {
         'branch': 'master',
     }}, {'project': project.name, 'commit': {
         'branch': 'develop',
     }}, {'project': project.name, 'commit': {
         'branch': 'master',
     }}, {'project': project.name, 'commit': {
         'branch': 'develop',
     }}])
     set(project.branches).should.be.equal({'master', 'develop'})
Esempio n. 33
0
 def test_unknown_because_last_task_not_finished(self):
     """Test unknown because not tasks performed"""
     project = factories.ProjectFactory.create()
     Tasks.insert([{
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     }, {
         'created': datetime(2011, 11, 11),
         'status': const.STATUS_NEW,
         'project': project.name,
     }])
     self._get_and_assert(project.name, 'unknown')
Esempio n. 34
0
 def test_update_quality_game_with_violations(self):
     """Test update quality game with violations"""
     project = factories.ProjectFactory()
     Tasks.save({
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() - timedelta(hours=5),
         'commit': {
             'branch': 'test',
             'author': 'test',
             'inner': [{
                 'author': {
                     'url': 'test'
                 }
             }]
         },
         'violations': [
             {
                 'name': 'cat',
                 'success_percent': 10
             },
         ],
     })
     project.update_quality_game({
         'project':
         project.name,
         'success_percent':
         15,
         'status':
         STATUS_SUCCESS,
         'created':
         datetime.now(),
         'commit': {
             'branch': 'test',
             'author': 'test',
             'inner': [{
                 'author': {
                     'url': 'test'
                 }
             }]
         },
         'violations': [
             {
                 'name': 'cat',
                 'success_percent': 15
             },
         ],
     })
     project.quality_game['violations']['cat']['test']['value']\
         .should.be.equal(1)
Esempio n. 35
0
 def test_fail_with_wrong_project(self):
     """Test fail with wrong project"""
     task_id = Tasks.save({
         'project': 'test',
         'service': {
             'name': 'token',
             'token': ProjectFactory().token,
         }
     })
     data = Tasks.find_one(task_id)
     with LogCapture() as log_capture:
         token_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(0)
Esempio n. 36
0
def AddTasks(request):
    page_data = {"AddTask_form": AddTask}
    if request.method == 'POST':
        AddTask_form = AddTask(request.POST)
        if (AddTask_form.is_valid()):
            desc = AddTask_form.cleaned_data["Description"]
            chois = AddTask_form.cleaned_data["Category"]
            task = Tasks()
            task.username = request.user
            task.description = desc
            task.completed = False
            sel_category = TaskCategory.objects.filter(id=str(int(chois) +
                                                              10)).get()
            task.category = sel_category
            task.save()
            status_object = HiddenStatus.objects.get(id=4)
            if status_object.status:
                page_data = fillpagedata(request.user, True)
                enable = True
            else:
                page_data = fillpagedata(request.user, False)
                enable = False
            return render(request, 'tasks/tasks.html', {
                "dat": page_data,
                "enabled": enable
            })

    return render(request, 'tasks/AddTasks.html', context=page_data)
Esempio n. 37
0
def topJobs():
    images = ("/mowing.jpg", "/grocery.jpg", "/cleaning.jpg", "/shoveling.jpg",
              "/moving.jpg", "/plumbing.jpg")

    tasks = ('Mow Lawn', 'Groceries', 'Clean House', 'Snow Shoveling',
             'Moving', 'Plumbing')

    links = ('mowing/', 'grocery/', 'cleaning/', 'shoveling/', 'moving/',
             'plumbing/')

    p = zip(tasks, images, links)

    for t in p:
        q = Tasks(Task=t[0], Photo=t[1], Link=t[2])
        q.save()
Esempio n. 38
0
 def _create_task(self, **kwargs):
     defaults = {
         'project': self.project.name,
         'status': STATUS_SUCCESS,
     }
     defaults.update(kwargs)
     return Tasks.save(defaults)
Esempio n. 39
0
def token_service(data):
    """Find project by token and create task

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId or None -- pk of created task
    """
    try:
        project = Project.objects.get(token=data['service']['token'])

        assert data['project'] == project.name

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Token service fail: {}'.format(e))
Esempio n. 40
0
 def test_get_last_task(self):
     """Test get last task"""
     project = factories.ProjectFactory()
     task_id = Tasks.save({
         'project': project.name,
         'commit': {'branch': 'branch'},
     })
     project.get_last_task()['_id'].should.be.equal(task_id)
Esempio n. 41
0
def dummy_service(data):
    """Create task from data dict

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId -- pk of created task
    """
    task_id = Tasks.save(data)
    return task_id
Esempio n. 42
0
 def test_attach_last_task(self):
     """Test attach last task"""
     project = factories.ProjectFactory(owner=self.user)
     task_id = Tasks.save({
         'project': project.name,
     })
     response = self.api_client.get(
         '{}{}/?with_last_task=true'.format(self.url, project.name), )
     self.deserialize(response)['last_task']['_id'].should.be\
         .equal(str(task_id))
Esempio n. 43
0
 def test_get_last_task(self):
     """Test get last task"""
     project = factories.ProjectFactory()
     task_id = Tasks.save({
         'project': project.name,
         'commit': {
             'branch': 'branch'
         },
     })
     project.get_last_task()['_id'].should.be.equal(task_id)
Esempio n. 44
0
def create_task(request):
    response = json.loads(request.body)
    title = response['title']
    description = response['description']
    task_date = response['date']
    token = response['token']
    print(token)
    user_id = jwt.decode(token, 'secret', algorithm='HS256')['user_id']
    u = User.objects.get(id=user_id)
    t = Tasks(title=title,
              description=description,
              task_date=task_date,
              owner=u)
    t.save()

    newTask = Tasks.objects.filter(id=t.id)

    serialized_queryset = serializers.serialize('python', newTask)
    return JsonResponse(serialized_queryset, safe=False)
 def test_attach_last_task(self):
     """Test attach last task"""
     project = factories.ProjectFactory(owner=self.user)
     task_id = Tasks.save({
         'project': project.name,
     })
     response = self.api_client.get(
         '{}{}/?with_last_task=true'.format(self.url, project.name),
     )
     self.deserialize(response)['last_task']['_id'].should.be\
         .equal(str(task_id))
 def test_attach_success_percent_only_with_dashboard_branch(self):
     """Test attach success percent only with dashboard branch"""
     project = factories.ProjectFactory(
         owner=self.user, dashboard_branch='branch',
     )
     Tasks.insert([{
         'project': project.name,
         'commit': {'branch': 'branch'},
         'created': datetime(2005, 5, 5),
         'success_percent': 12,
     }, {
         'project': project.name,
         'commit': {'branch': 'test'},
         'created': datetime(2006, 5, 5),
         'success_percent': 92,
     }])
     response = self.api_client.get(
         '{}{}/?with_success_percent=true'.format(self.url, project.name),
     )
     self.deserialize(response)['success_percents'].should.be.equal([12])
Esempio n. 47
0
    def get_context_data(self, **kwargs):
        """Get day statistic"""
        success = Tasks.find({'created': {
            '$gte': datetime.now() - timedelta(days=1)
        }, 'status': STATUS_SUCCESS}).count()

        failed = Tasks.find({'created': {
            '$gte': datetime.now() - timedelta(days=1)
        }, 'status': STATUS_FAILED}).count()

        if failed:
            failed_percent = failed * 100 / (success + failed)
        else:
            failed_percent = 0

        return {
            'failed': failed_percent,
            'success': 100 - failed_percent,
            'debug': settings.DEBUG,
            'site': Site.objects.get_current(),
        }
Esempio n. 48
0
def travis_ci_service(data):
    """Create tasks from data received from travis-c

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId or None -- pk of created task
    """
    try:
        assert Tasks.find({
            'service.name': 'travis_ci',
            'service.job_id': data['service']['job_id'],
        }).count() <= 1

        job = requests.get(
            'https://api.travis-ci.org/jobs/{}'.format(
                data['service']['job_id'],
            ),
        ).json()

        repo = requests.get(
            'https://api.travis-ci.org/repos/{}'.format(
                job['repository_id'],
            ),
        ).json()

        # TODO: add pull request support
        assert data['project'] == repo['slug']

        if data['service'].get('pull_request_id'):
            pull_request = data['service']['pull_request_id']
            if pull_request != 'false':
                data['pull_request_id'] = int(
                    data['service']['pull_request_id'],
                )

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Travis-ci service fail: {}'.format(e))
Esempio n. 49
0
def coviolations_service(data):
    """Find project by token and create task

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId or None -- pk of created task
    """
    try:
        project = Project.objects.get(token=data['service']['token'])
        node_task = NodeTask.objects.get(
            id=data['service']['task_id'],
            project=project,
        )
        data['commit']['branch'] = node_task.branch

        assert data['project'] == project.name

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Token service fail: {}'.format(e))
Esempio n. 50
0
    def test_task_creation(self):
        task = Tasks(**TASK)
        task.priority = self.priority
        task.user = self.user

        task.save()

        self.assertEqual(task.name, 'ver el partido')
Esempio n. 51
0
 def get_last_task(self):
     """Get last task"""
     task = Tasks.find_one({
         'project': self.name,
     }, sort=[('created', DESCENDING)], fields={
         name: True for name in (
             'service', 'project', 'commit', 'plot',
             'created', 'status', 'success_percent',
         )
     })
     if task:
         return task
     else:
         raise TaskDoesNotExists()
Esempio n. 52
0
 def _fill_statistic_parts(self, parts, grouper):
     """Fill statistic parts"""
     for task in Tasks.find({
         'project': self.name,
         'created': {'$exists': True},
         'success_percent': {'$exists': True},
     }):
         if type(task['created']) is datetime:
             group = grouper(task)
             parts[group]['count'] += 1
             parts[group]['sum_percent'] +=\
                 task['success_percent']
             parts[group][
                 'success' if task['status'] == STATUS_SUCCESS else 'failed'
             ] += 1
Esempio n. 53
0
 def get_success_percents(self, count, branch=None):
     """Get project last success percents"""
     if branch is None:
         branch = self.dashboard_branch
     spec = {
         'project': self.name,
     }
     if branch:
         spec['commit.branch'] = branch
     return [
         task.get('success_percent', 0) for task in Tasks.find(
             spec, sort=[('created', DESCENDING)], fields={
                 'success_percent': True,
             }, limit=count)
     ]
Esempio n. 54
0
def create_task(request):
    json_value = {}
    module_code = "04"
    module_status = ""
    if request.method == 'POST':
        if request.user.is_authenticated():
            if all(key in request.POST for key in ('name', 'description', 'priority', 'state', 'due_date')):
                name = request.POST['name']
                description = request.POST['description']
                priority = request.POST['priority']
                state = request.POST['state']
                due_date = request.POST['due_date']
                if priority and state and name and description and due_date:
                    if 1 <= int(priority) <= 5 and 1 <= int(state) <= 3:
                        task_object = Tasks()
                        task_object.name = name
                        task_object.description = description
                        task_object.priority = priority
                        task_object.state = state
                        task_object.due_date = due_date
                        task_object.user = request.user
                        try:
                            task_object.save()
                            module_status = "01"  # success
                        except ValidationError:
                            module_status = "00"  # post data; date field format not correct yyyy-mm-dd
                    else:
                        module_status = "00"  # post data error
                else:
                    module_status = "00"  # post data error
            else:
                module_status = "00"  # post data error
        else:
            module_status = "02"  # user not logged in
    else:
        module_status = "00"  # method not post
    json_value['status_code'] = module_code + module_status
    return_value = json.dumps(json_value)
    return HttpResponse(return_value)