def new_committee(**kwargs): c = Committee(name=kwargs.pop('name', 'testCommittee'), full_name=kwargs.pop('fullName', 'testCommittee'), delegation_size=kwargs.pop('delegation_size', 10), special=kwargs.pop('special', False)) c.save() return c
def new_committee(**kwargs): c = Committee( name=kwargs.pop('name', 'testCommittee'), full_name=kwargs.pop('fullName', 'testCommittee'), delegation_size=kwargs.pop('delegation_size', 10), special=kwargs.pop('special', False)) c.save() return c
def new_committee(**kwargs): c = Committee( name=kwargs.pop("name", "testCommittee"), full_name=kwargs.pop("fullName", "testCommittee"), delegation_size=kwargs.pop("delegation_size", 10), special=kwargs.pop("special", False), ) c.save() return c
def load(self, request): '''Import a CSV file containing committees.''' committees = request.FILES reader = csv.reader(committees['csv']) for row in reader: com = Committee(name=row[0], full_name=row[1], delegation_size=int(row[2]), special=bool(row[3])) com.save() return HttpResponseRedirect(reverse('admin:core_committee_changelist'))
def load(self, request): '''Import a CSV file containing committees.''' committees = request.FILES reader = csv.reader(committees['csv'].read().decode('utf-8').splitlines()) for row in reader: if row: special = False if row[3] == '0' or row[3] == 'False' or not row[3] else True com = Committee(name=row[0], full_name=row[1], delegation_size=int(row[2]), special=special) com.save() return HttpResponseRedirect(reverse('admin:core_committee_changelist'))
def new_committee(**kwargs): c = Committee( name=kwargs.pop('name', 'testCommittee'), full_name=kwargs.pop('fullName', 'testCommittee'), delegation_size=kwargs.pop('delegation_size', 10), special=kwargs.pop('special', False)) c.save() user = kwargs.pop('user', None) for attr, value in kwargs.items(): setattr(c, attr, value) c.save() if user is None: new_user( username=str(uuid.uuid4()), committee=c, user_type=User.TYPE_CHAIR) else: user.committee = c user.save() return c
def test_create_rubric(self): '''Tests that a committee creates a new rubric upon being saved for the first time, but not on subsequent saves.''' c = Committee( name='DISC', full_name='Disarmament and International Security') self.assertTrue(c.rubric == None) c.save() self.assertTrue(c.rubric != None) rubric_id = c.rubric.id c.rubric.grade_category_1 = "Overall paper quality" c.rubric.save() c.save() self.assertEquals(c.rubric.grade_category_1, "Overall paper quality") self.assertEquals(c.rubric.id, rubric_id) c.rubric = None c.save() self.assertFalse(c.rubric == None) self.assertFalse(c.rubric.id == rubric_id)