def handle(self, *args, **options): """handle""" print "Validating quests ..." for quest in Quest.objects.all(): error_msg = predicate_mgr.validate_predicates(quest.unlock_conditions) if error_msg: print "Unlock conditions for '%s' did not validate: %s" % (quest.name, error_msg) error_msg = predicate_mgr.validate_predicates(quest.completion_conditions) if error_msg: print "Completion conditions '%s' for '%s' did not validate: %s" % ( quest.completion_conditions, quest.name, error_msg) print "All quests conditions are valid."
def handle(self, *args, **options): """handle""" print "Validating smartgrid ..." for action in Action.objects.all(): error_msg = predicate_mgr.validate_predicates(action.unlock_condition) if error_msg: print "Unlock conditions '%s' for action '%s' did not validate: %s" % ( action.unlock_condition, action.name, error_msg) for level in Level.objects.all(): error_msg = predicate_mgr.validate_predicates(level.unlock_condition) if error_msg: print "Unlock conditions '%s' for level '%s' did not validate: %s" % ( level.unlock_condition, level.name, error_msg) print "All smartgrid conditions are valid."
def handle(self, *args, **options): """handle""" print "Validating quests ..." for quest in Quest.objects.all(): error_msg = predicate_mgr.validate_predicates( quest.unlock_conditions) if error_msg: print "Unlock conditions for '%s' did not validate: %s" % ( quest.name, error_msg) error_msg = predicate_mgr.validate_predicates( quest.completion_conditions) if error_msg: print "Completion conditions '%s' for '%s' did not validate: %s" % ( quest.completion_conditions, quest.name, error_msg) print "All quests conditions are valid."
def handle(self, *args, **options): """handle""" print "Validating smartgrid ..." for action in Action.objects.all(): error_msg = predicate_mgr.validate_predicates( action.unlock_condition) if error_msg: print "Unlock conditions '%s' for action '%s' did not validate: %s" % ( action.unlock_condition, action.name, error_msg) for level in Level.objects.all(): error_msg = predicate_mgr.validate_predicates( level.unlock_condition) if error_msg: print "Unlock conditions '%s' for level '%s' did not validate: %s" % ( level.unlock_condition, level.name, error_msg) print "All smartgrid conditions are valid."
def add_level(request, draft_slug): """Creates a new level.""" draft = smartgrid_mgr.get_designer_draft(draft_slug) if request.method == 'POST': form = AddLevelForm(request.POST) if form.is_valid(): max_priority = 0 for level in DesignerLevel.objects.filter(draft=draft): if max_priority < level.priority: max_priority = level.priority max_priority += 1 slug = slugify(form.cleaned_data['level_name']) level = DesignerLevel(name=form.cleaned_data['level_name'], slug=slug, \ priority=max_priority, draft=draft) predicate = form.cleaned_data['unlock_condition'] if not predicate_mgr.validate_predicates(predicate): level.unlock_condition = predicate else: level.unlock_condition = 'False' # What is the correct default value? level.save() response = HttpResponseRedirect("/sgg_designer/?draft=%s" % draft.slug) return response