def automatch_productions(releaser): unmatched_demozoo_prods, unmatched_janeway_prods, matched_prods = get_production_match_data( releaser) matched_production_count = len(matched_prods) unmatched_demozoo_production_count = len(unmatched_demozoo_prods) unmatched_janeway_production_count = len(unmatched_janeway_prods) # mapping of lowercased prod title to a pair of lists of demozoo IDs and pouet IDs of # prods with that name prods_by_name_and_supertype = defaultdict(lambda: ([], [])) for id, title, url, supertype in unmatched_demozoo_prods: prods_by_name_and_supertype[(generate_search_title(title), supertype)][0].append(id) for id, title, url, supertype in unmatched_janeway_prods: if supertype == 'music': title = strip_music_extensions(title) prods_by_name_and_supertype[(generate_search_title(title), supertype)][1].append(id) just_matched_janeway_ids = set() for (title, supertype), (demozoo_ids, janeway_ids) in prods_by_name_and_supertype.items(): if len(demozoo_ids) == 1 and len(janeway_ids) == 1: ProductionLink.objects.create( production_id=demozoo_ids[0], link_class='KestraBitworldRelease', parameter=janeway_ids[0], is_download_link=False, source='janeway-automatch', ) just_matched_janeway_ids.add(janeway_ids[0]) matched_production_count += 1 unmatched_demozoo_production_count -= 1 unmatched_janeway_production_count -= 1 if unmatched_demozoo_production_count == 0: # all matchable prods are accounted for, so let's go on and import the remaining ones from janeway for id, title, url, supertype in unmatched_janeway_prods: if id in just_matched_janeway_ids: continue import_release(JanewayRelease.objects.get(janeway_id=id)) matched_production_count += 1 unmatched_janeway_production_count -= 1 AuthorMatchInfo.objects.update_or_create( releaser_id=releaser.id, defaults={ 'matched_production_count': matched_production_count, 'unmatched_demozoo_production_count': unmatched_demozoo_production_count, 'unmatched_janeway_production_count': unmatched_janeway_production_count, })
def test_import_soundtracklink_prod_first(self): import_release(Release.objects.get(title="State Of The Art")) import_release(Release.objects.get(title="mod.condom_corruption")) sota = Production.objects.get(title="State Of The Art") self.assertTrue( sota.soundtrack_links.filter( soundtrack__title="condom_corruption").exists())
def test_import_packcontent_member_first(self): import_release(Release.objects.get(title="State Of The Art")) import_release(Release.objects.get(title="Spaceballs Pack 1")) pack = Production.objects.get(title="Spaceballs Pack 1") self.assertTrue( pack.pack_members.filter( member__title="State Of The Art").exists())
def import_all_author_productions(request): if not request.user.is_staff: return redirect('home') releaser = get_object_or_404(Releaser, id=request.POST['releaser_id']) unmatched_demozoo_prods, unmatched_janeway_prods, matched_prods = get_production_match_data(releaser) for janeway_id, title, url, supertype in unmatched_janeway_prods: import_release(JanewayRelease.objects.get(janeway_id=janeway_id)) return redirect('janeway_match_author', releaser.id)
def test_releaser_without_nick_match(self): tmb_janeway = Author.objects.get(name="TMB Designs") tmb_demozoo = Releaser.objects.create(name="TMB", is_group=False) tmb_designs_nick = tmb_demozoo.nicks.create(name="not tmb designs") tmb_demozoo.external_links.create(link_class='KestraBitworldAuthor', parameter=tmb_janeway.janeway_id) import_author(Author.objects.get(name="Spaceballs")) import_release(Release.objects.get(title="State Of The Art")) self.assertTrue( Production.objects.get(title="State Of The Art").credits.filter( nick=tmb_demozoo.primary_nick).exists())
def test_import_member_first(self): import_author(Author.objects.get(name="TMB Designs")) import_author(Author.objects.get(name="Spaceballs")) import_release(Release.objects.get(title="State Of The Art")) self.assertTrue(Releaser.objects.filter(name="Spaceballs").exists()) self.assertTrue(Releaser.objects.filter(name="TMB Designs").exists()) self.assertTrue( Releaser.objects.get(name="TMB Designs").nicks.filter( name="TMB").exists()) self.assertTrue( Releaser.objects.get(name="Spaceballs").member_memberships.filter( member__name="TMB Designs").exists()) sota = Production.objects.get(title="State Of The Art") self.assertTrue(sota.credits.filter(nick__name="TMB Designs").exists()) self.assertTrue(sota.platforms.filter(name="Amiga OCS/ECS").exists())
def test_import_group_first(self): import_author(Author.objects.get(name="Spaceballs")) import_author(Author.objects.get(name="TMB Designs")) import_release(Release.objects.get(title="State Of The Art")) self.assertTrue(Releaser.objects.filter(name="Spaceballs").exists()) self.assertTrue(Releaser.objects.filter(name="TMB Designs").exists()) self.assertTrue( Releaser.objects.get(name="TMB Designs").nicks.filter( name="TMB").exists()) self.assertTrue( Releaser.objects.get(name="Spaceballs").member_memberships.filter( member__name="TMB Designs").exists()) sota = Production.objects.get(title="State Of The Art") self.assertTrue(sota.credits.filter(nick__name="TMB Designs").exists()) self.assertTrue(sota.platforms.filter(name="Amiga OCS/ECS").exists()) self.assertTrue( sota.links.filter( link_class='AmigascneFile', parameter='/Groups/S/Spaceballs/Spaceballs-StateOfTheArt.dms', source='janeway').exists())
def production_import(request): if not request.user.is_staff: return redirect('home') release = get_object_or_404(JanewayRelease, janeway_id=request.POST['janeway_id']) production = import_release(release) Edit.objects.create(action_type='create_production', focus=production, description=(u"Added production '%s' from Janeway import" % production.title), user=request.user) return render(request, 'janeway/_matched_production.html', { 'dz_id': production.id, 'dz_title': production.title, 'dz_url': production.get_absolute_url(), 'janeway_id': release.janeway_id, 'janeway_title': release.title, 'janeway_url': "http://janeway.exotica.org.uk/release.php?id=%s" % release.janeway_id, 'supertype': production.supertype, })
def test_import_ppc(self): import_release(Release.objects.get(title="Planet Potion")) planet_potion = Production.objects.get(title="Planet Potion") self.assertTrue( planet_potion.platforms.filter(name="Amiga PPC/RTG").exists())
def test_import_aga(self): import_release(Release.objects.get(title="Ocean Machine")) ocean_machine = Production.objects.get(title="Ocean Machine") self.assertTrue( ocean_machine.platforms.filter(name="Amiga AGA").exists())