def create_steam_installer(game): """Create a Lutris installer for a given game instance""" installer = models.Installer() installer.runner = models.Runner.objects.get(slug='steam') installer.user = User.objects.get(username='******') installer.game = game installer.set_default_installer() installer.published = True installer.save()
def setUp(self): self.game = factories.GameFactory(name="Doom") self.runner = factories.RunnerFactory(name='Linux') self.user = factories.UserFactory(first_name="test") self.installer = models.Installer() self.installer.slug = 'doom-shareware' self.installer.version = 'shareware' self.installer.game = self.game self.installer.runner = self.runner self.installer.user = self.user self.installer.save()
def clean(self): dummy_installer = models.Installer(game=self.instance.game, **self.cleaned_data) is_valid, errors = validate_installer(dummy_installer) if not is_valid: if "content" not in self.errors: self.errors["content"] = [] for error in errors: self.errors["content"].append(error) raise forms.ValidationError("Invalid installer script") # Draft status depends on the submit button clicked self.cleaned_data["draft"] = "save" in self.data return self.cleaned_data
def handle(self, *args, **options): with open("steamdb.json") as steamdb_file: steamdb = json.loads(steamdb_file.read()) steam_runner = models.Runner.objects.get(slug='steam') user = User.objects.get(username='******') for steamapp in steamdb: if steamapp['linux_status'].startswith('Game Works'): appid = steamapp['appid'] name = steamapp['name'] try: game = models.Game.objects.get(steamid=int(appid)) except models.Game.DoesNotExist: continue current_installer = game.installers.all() if current_installer: continue self.stdout.write("Creating installer for %s" % name) installer = models.Installer() installer.runner = steam_runner installer.user = user installer.game = game installer.set_default_installer() installer.published = True installer.save()