예제 #1
0
 def get(self):
     upload_url = blobstore.create_upload_url('/upload')
     contention_ID = self.request.get('con_id')
     con = Contention.get_by_id(int(contention_ID))
     con_date = con.date.strftime("%a, %d. %b %y, %I:%M%p")
     # for x in xrange(1, 11):
     # image_num = "image" + str(x)
     # if con(image_num):
     # con_image_urls[x]= get_serving_url(con(image_num))
     #return images.get_serving_url(self.image1)
     count = 0
     ari_query = Ari_types.all().order('ari')
     aris = ari_query.fetch(50)
     if con:
         elems = con.elements.fetch(50)
         count = int(elems.count(20)) + 1
     tlvl = []
     slvl = []
     for f in elems:
         if f.top_level == 1:
             tlvl.append(f)
         else:
             slvl.append(f)
     gols = rec_con(tlvl, slvl)
     objections = []
     reasons = []
     rcount = 0
     ocount = 0
     ccount = 0
     #contention_query =  Contention.all().order('date')
     if con:
         if elems:
             for r in elems:
                 if r.element_type == 'reason':
                     reasons.append(r)
                     rcount = rcount + 1
             for o in elems:
                 if o.element_type == 'objection':
                     objections.append(o)
                     ocount = ocount + 1
         ccount = int(len(elems))
     branch_query = Branch.all().order('branch')
     branches = branch_query.fetch(10)
     params = {
         'upload_url': upload_url,
         'c_id': contention_ID,
         'con': con,
         'con_date': con_date,
         'reasons': reasons,
         'objections': objections,
         'ccount': ccount,
         'rcount': rcount,
         'ocount': ocount,
         'elems': elems,
         'gols': gols,
         'count': count,
         "branches": branches,
         'aris': aris
     }
     return self.render('contention_panel_view.html', params)
예제 #2
0
    def __init__(self):
        # FIXME: This function is massive. Break it up
        self._test_map = {}
        platform_id_map = {}
        branch_id_map = {}
        for test in Test.all():
            if test.hidden:
                continue

            branch_ids = [Branch.get(branch_key).id for branch_key in test.branches]
            platform_ids = [Platform.get(platform_key).id for platform_key in test.platforms]
            self._test_map[test.id] = {
                'name': test.name,
                'branchIds': branch_ids,
                'platformIds': platform_ids,
            }

            for platform_id in platform_ids:
                platform_id_map.setdefault(platform_id, {'tests': [], 'branches': []})
                platform_id_map[platform_id]['tests'].append(test.id)
                platform_id_map[platform_id]['branches'] += branch_ids

            for branch_id in branch_ids:
                branch_id_map.setdefault(branch_id, {'tests': [], 'platforms': []})
                branch_id_map[branch_id]['tests'].append(test.id)
                branch_id_map[branch_id]['platforms'] += platform_ids

        self._platform_map = {}
        for platform in Platform.all():
            if platform.id not in platform_id_map:
                continue

            if platform.hidden:
                for test_id in platform_id_map[platform.id]['tests']:
                    self._test_map[test_id]['platformIds'].remove(platform.id)
                for branch_id in platform_id_map[platform.id]['branches']:
                    branch_id_map[branch_id]['platforms'].remove(platform.id)
                continue

            self._platform_map[platform.id] = {
                'name': platform.name,
                'testIds': list(set(platform_id_map[platform.id]['tests'])),
                'branchIds': list(set(platform_id_map[platform.id]['branches'])),
            }

        self._branch_map = {}
        for branch in Branch.all():
            if branch.id not in branch_id_map:
                continue
            self._branch_map[branch.id] = {
                'name': branch.name,
                'testIds': list(set(branch_id_map[branch.id]['tests'])),
                'platformIds': list(set(branch_id_map[branch.id]['platforms'])),
            }
예제 #3
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8';
        cache = memcache.get('manifest')
        if cache:
            self.response.out.write(cache)
            return

        testMap = {}
        platformIdMap = {}
        branchIdMap = {}
        for test in Test.all():
            branchIds = [Branch.get(branchKey).id for branchKey in test.branches]
            platformIds = [Platform.get(platformKey).id for platformKey in test.platforms]
            testMap[test.id] = {
                'name': test.name,
                'branchIds': branchIds,
                'platformIds': platformIds,
            }

            for platformId in platformIds:
                platformIdMap.setdefault(platformId, {'tests': [], 'branches': []})
                platformIdMap[platformId]['tests'].append(test.id)
                platformIdMap[platformId]['branches'] += branchIds

            for branchId in branchIds:
                branchIdMap.setdefault(branchId, {'tests': [], 'platforms': []})
                branchIdMap[branchId]['tests'].append(test.id)
                branchIdMap[branchId]['platforms'] += platformIds

        platformMap = {}
        for platform in Platform.all():
            if platform.id not in platformIdMap:
                continue
            platformMap[platform.id] = {
                'name': platform.name,
                'testIds': list(set(platformIdMap[platform.id]['tests'])),
                'branchIds': list(set(platformIdMap[platform.id]['branches'])),
            }

        branchMap = {}
        for branch in Branch.all():
            if branch.id not in branchIdMap:
                continue
            branchMap[branch.id] = {
                'name': branch.name,
                'testIds': list(set(branchIdMap[branch.id]['tests'])),
                'platformIds': list(set(branchIdMap[branch.id]['platforms'])),
            }

        result = json.dumps({'testMap': testMap, 'platformMap': platformMap, 'branchMap': branchMap})
        self.response.out.write(result)
        memcache.add('manifest', result)
예제 #4
0
    def get(self):
        self.response.headers["Content-Type"] = "text/plain; charset=utf-8"
        self.response.out.write('{"testMap":')

        testMap = {}
        platformIdMap = {}
        branchIdMap = {}
        for test in Test.all():
            branchIds = [Branch.get(branchKey).id for branchKey in test.branches]
            platformIds = [Platform.get(platformKey).id for platformKey in test.platforms]
            testMap[test.id] = {"name": test.name, "branchIds": branchIds, "platformIds": platformIds}

            for platformId in platformIds:
                platformIdMap.setdefault(platformId, {"tests": [], "branches": []})
                platformIdMap[platformId]["tests"].append(test.id)
                platformIdMap[platformId]["branches"] += branchIds

            for branchId in branchIds:
                branchIdMap.setdefault(branchId, {"tests": [], "platforms": []})
                branchIdMap[branchId]["tests"].append(test.id)
                branchIdMap[branchId]["platforms"] += platformIds

        self.response.out.write(json.dumps(testMap))
        self.response.out.write(',"platformMap":')

        platformMap = {}
        for platform in Platform.all():
            if platform.id not in platformIdMap:
                continue
            platformMap[platform.id] = {
                "name": platform.name,
                "testIds": list(set(platformIdMap[platform.id]["tests"])),
                "branchIds": list(set(platformIdMap[platform.id]["branches"])),
            }

        self.response.out.write(json.dumps(platformMap))
        self.response.out.write(',"branchMap":')

        branchMap = {}
        for branch in Branch.all():
            if branch.id not in branchIdMap:
                continue
            branchMap[branch.id] = {
                "name": branch.name,
                "testIds": list(set(branchIdMap[branch.id]["tests"])),
                "platformIds": list(set(branchIdMap[branch.id]["platforms"])),
            }

        self.response.out.write(json.dumps(branchMap))
        self.response.out.write("}")
예제 #5
0
    def test_create_in_transaction_with_numeric_id_holder(self):

        def execute(id):
            return Branch(id=id, name='some branch', key_name='some-branch').put()

        self.assertThereIsNoInstanceOf(Branch)
        self.assertThereIsNoInstanceOf(NumericIdHolder)

        self.assertTrue(create_in_transaction_with_numeric_id_holder(execute))

        branches = Branch.all().fetch(5)
        self.assertEqual(len(branches), 1)
        self.assertEqual(branches[0].name, 'some branch')
        self.assertEqual(branches[0].key().name(), 'some-branch')

        self._assert_there_is_exactly_one_id_holder_and_matches(branches[0].id)
예제 #6
0
    def test_create_in_transaction_with_numeric_id_holder(self):

        def execute(id):
            return Branch(id=id, name='some branch', key_name='some-branch').put()

        self.assertThereIsNoInstanceOf(Branch)
        self.assertThereIsNoInstanceOf(NumericIdHolder)

        self.assertTrue(create_in_transaction_with_numeric_id_holder(execute))

        branches = Branch.all().fetch(5)
        self.assertEqual(len(branches), 1)
        self.assertEqual(branches[0].name, 'some branch')
        self.assertEqual(branches[0].key().name(), 'some-branch')

        self._assert_there_is_exactly_one_id_holder_and_matches(branches[0].id)
예제 #7
0
    def get(self):
        contention_query = Contention.all().order('-date')
        cons = contention_query.fetch(10)
        count = "0"  #int(cons.count(10))+1
        branch_query = Branch.all().order('branch')
        branches = branch_query.fetch(10)
        #images = con.images.fetch(10)

        # if users.get_current_user():
        # url = users.create_logout_url(self.request.uri)
        # url_linktext = 'Logout'
        # else:
        # url = users.create_login_url(self.request.uri)
        # url_linktext = 'Login'

        params = {
            'cons': cons,
            'branches': branches,
            'count': count,
        }
        return self.render('index.html', params)
예제 #8
0
    def __init__(self):
        # FIXME: This function is massive. Break it up
        self._test_map = {}
        platform_id_map = {}
        branch_id_map = {}
        for test in Test.all():
            if test.hidden:
                continue

            branch_ids = [
                Branch.get(branch_key).id for branch_key in test.branches
            ]
            platform_ids = [
                Platform.get(platform_key).id
                for platform_key in test.platforms
            ]
            self._test_map[test.id] = {
                'name': test.name,
                'branchIds': branch_ids,
                'platformIds': platform_ids,
            }

            for platform_id in platform_ids:
                platform_id_map.setdefault(platform_id, {
                    'tests': [],
                    'branches': []
                })
                platform_id_map[platform_id]['tests'].append(test.id)
                platform_id_map[platform_id]['branches'] += branch_ids

            for branch_id in branch_ids:
                branch_id_map.setdefault(branch_id, {
                    'tests': [],
                    'platforms': []
                })
                branch_id_map[branch_id]['tests'].append(test.id)
                branch_id_map[branch_id]['platforms'] += platform_ids

        self._platform_map = {}
        for platform in Platform.all():
            if platform.id not in platform_id_map:
                continue

            if platform.hidden:
                for test_id in platform_id_map[platform.id]['tests']:
                    self._test_map[test_id]['platformIds'].remove(platform.id)
                for branch_id in platform_id_map[platform.id]['branches']:
                    branch_id_map[branch_id]['platforms'].remove(platform.id)
                continue

            self._platform_map[platform.id] = {
                'name': platform.name,
                'testIds': list(set(platform_id_map[platform.id]['tests'])),
                'branchIds':
                list(set(platform_id_map[platform.id]['branches'])),
            }

        self._branch_map = {}
        for branch in Branch.all():
            if branch.id not in branch_id_map:
                continue
            self._branch_map[branch.id] = {
                'name': branch.name,
                'testIds': list(set(branch_id_map[branch.id]['tests'])),
                'platformIds':
                list(set(branch_id_map[branch.id]['platforms'])),
            }
예제 #9
0
 def get_branches(self):
     self.response.headers['Content-Type'] = 'application/json'
     result = {}
     for branch in Branch.all().fetch(limit=100):
         result[branch.key().name()] = branch.name
     self.response.out.write(json.dumps(result))
예제 #10
0
    def get(self):
        branch_query = Branch.all().order('branch')
        branches = branch_query.fetch(10)

        params = {'branches': branches}
        return self.render('menu.html', params)
예제 #11
0
    def get(self):
        edit = self.request.get('edit')
        type = self.request.get('type')
        #contention_query =  Contention.all().order('-date')
        #cons = contention_query.fetch(10)
        #count = int(cons.count(10))+1
        branch_query = Branch.all().order('branch')
        branches = branch_query.fetch(10)
        ari_query = Ari_types.all().order('ari')
        aris = ari_query.fetch(50)
        if edit == "0" or edit == "":
            p_type = "contention"
            params = {
                'branches': branches,
                'con': "",
                'reasons': "",
                'objections': "",
                'edit': edit,
                'p_type': p_type,
                'aris': aris
            }
        elif edit == "1":
            contention_ID = self.request.get('c_id')
            con = Contention.get_by_id(int(contention_ID))
            p_type = "contention"
            reasons = {}
            objections = {}
            if con:
                elems = con.elements.fetch(50)
                count = int(elems.count(20)) + 1
                rsn = 0
                objn = 0
                for f in elems:
                    if f.top_level == 1:
                        if f.element_type == 'reason':
                            rsn = rsn + 1
                            reasons['reason' + str(rsn)] = f
                        if f.element_type == 'objection':
                            objn = objn + 1
                            objections['objection' + str(objn)] = f
            params = {
                'branches': branches,
                'edit': edit,
                'p_type': p_type,
                'con': con,
                'elems': elems,
                'reasons': reasons,
                'objections': objections,
                'aris': aris,
                #'count': count,
            }
        elif edit == "2":
            contention_ID = self.request.get('c_id')
            con = Contention.get_by_id(int(contention_ID))
            p_type = "element"
            reasons = []
            objections = []
            if con:
                elems = con.elements.fetch(50)
                count = int(elems.count(20)) + 1
                elem_ID = int(self.request.get('e_id'))
                rsn = 0
                objn = 0
                for f in elems:
                    if f.parent_id == elem_ID:
                        if f.element_type == 'reason':
                            rsn = rsn + 1
                            reasons['reason' + str(rsn)] = f
                        if f.element_type == 'objection':
                            objn = objn + 1
                            objections['objection' + str(objn)] = f
            #edit_gols['subnodes']=slvl
            elem_ID = self.request.get('e_id')
            elem = Elements.get_by_id(int(elem_ID))
            params = {
                'branches': branches,
                'edit': edit,
                'p_type': p_type,
                'con': con,
                'elem': elem,
                'reasons': reasons,
                'objections': objections,
                'aris': aris,
                'form_url': blobstore.create_upload_url('/upload')
                #'count': count,
            }

        # if users.get_current_user():
        # url = users.create_logout_url(self.request.uri)
        # url_linktext = 'Logout'
        # else:
        # url = users.create_login_url(self.request.uri)
        # url_linktext = 'Login'

        return self.render('argu_form.html', params)
예제 #12
0
 def get_branches(self):
     self.response.headers['Content-Type'] = 'application/json'
     result = {}
     for branch in Branch.all():
         result[branch.key().name()] = {'name': branch.name}
     self.response.out.write(json.dumps(result))