def mturk_data_source(config): recruiter = recruiters.from_config(config) try: return MTurkDataSource(recruiter) except NotUsingMTurkRecruiter: if config.get("mode") == "debug": flash( "Debug mode: Fake MTurk information provided for testing only.", "warning", ) return FakeMTurkDataSource() else: raise
def mturk_data_source(config): recruiter = recruiters.from_config(config) try: return MTurkDataSource(recruiter) except NotUsingMTurkRecruiter: if config.get("mode") == "debug": flash( "Since you're in debug mode, you're seeing fake data for testing.", "danger", ) return FakeMTurkDataSource() else: raise
def database(): from dallinger.experiment_server.experiment_server import Experiment, session title = "Database View" exp = Experiment(session) model_type = request.args.get("model_type") if model_type: title = "Database View: {}s".format(model_type) datatables_options = prep_datatables_options( exp.table_data(**request.args.to_dict(flat=False))) columns = [ c.get("name") or c["data"] for c in datatables_options.get("columns", []) if c.get("data") ] # Extend with custom actions actions = { "extend": "collection", "text": "Actions", "buttons": [], } buttons = actions["buttons"] exp_actions = exp.dashboard_database_actions() for action in exp_actions: buttons.append({ "extend": "route_action", "text": action["title"], "route_name": action["name"], }) is_sandbox = getattr(recruiters.from_config(get_config()), "is_sandbox", None) if is_sandbox is True or is_sandbox is False: buttons.append("compensate") else: is_sandbox = None if len(buttons): datatables_options["buttons"].append(actions) return render_template( "dashboard_database.html", title=title, columns=columns, is_sandbox=is_sandbox, datatables_options=json.dumps(datatables_options, default=date_handler, indent=True), )
def recruiter(self): """Reference to a Recruiter, the Dallinger class that recruits participants. """ return recruiters.from_config(get_config())