def create_partner(self): """Create a new random partner""" partner = Partner() partner.is_active = random.random() < 0.75 partner.name = "{} {}".format(_faker.company(), _faker.company_suffix()) partner.slug = _faker.slug() partner.link = _faker.uri() igen = IconGenerator(5, 5) # 5x5 blocks icon = igen.generate( partner.name, 480, 480, padding=(10, 10, 10, 10), output_format="jpeg", ) # 620x620 pixels, with 10 pixels padding on each side partner.logo.save(partner.name + ".jpeg", ContentFile(icon)) partner.address = _faker.street_address() partner.zip_code = _faker.postcode() partner.city = _faker.city() partner.save()
def create(self, validated_data): request = self.context['request'] instance = Partner(**validated_data) instance.save() for i in request.FILES.getlist('file'): f = PartnerFile(partner=instance, file=i) f.save() return instance
def setup(self): self.equipment = Equipment() self.partner = Partner(name='partner') self.equipment.save() self.partner.save()
state = State(name=state['Name']) state.save() # with open('play.json') as f: # play_json = json.load(f) # for play in play_json: # play = Play(name=play['play']) # play.save() with open('2019_June_partners.json') as f: partners_json = json.load(f) for partner in partners_json: partner = Partner(name=partner['name'], type=partner['type'], act_id=partner['act_id'], active=partner['active']) partner.save() with open('2019_June_Oxy_rigs.json') as f: rigs_json = json.load(f) for rig in rigs_json: rig = Rig(name=rig['name'], partner=Partner.objects.get(pk=int(rig['partner'])), company=rig['company'], active=rig['active']) rig.save() with open('districts.json') as f: districts_json = json.load(f)