def status_label(inst): """Return a span label styled based on the instance's current status""" inst_type = utils.get_type_from_instance(inst) state = get_status_from_instance(inst).upper() state_cls = 'info' if inst_type == 'user': if not inst.email_verified or not inst.moderated: state_cls = 'warning' elif inst.is_rejected: state_cls = 'danger' elif inst.is_active: state_cls = 'success' elif not inst.is_active: state_cls = 'inverse' else: state_cls = status_map[inst_type].get(state, 'info') label_cls = "label label-%s" % state_cls if inst_type in ["project", "application"]: name = inst_type.capitalize() + " Status: " else: name = "" deleted_label = "" if getattr(inst, 'deleted', False): deleted_label = '<span class="label label-danger">Deleted</span>' return '%s\n<span class="%s">%s%s</span>' % (deleted_label, label_cls, name, state)
def status_label(inst): """Return a span label styled based on the instance's current status""" inst_type = utils.get_type_from_instance(inst) state = get_status_from_instance(inst).upper() state_cls = 'info' if inst_type == 'user': if not inst.email_verified or not inst.moderated: state_cls = 'warning' elif inst.is_rejected: state_cls = 'danger' elif inst.is_active: state_cls = 'success' elif not inst.is_active: state_cls = 'inverse' else: state_cls = status_map[inst_type].get(state, 'info') label_cls = "label label-%s" % state_cls if inst_type in ["project", "application"]: name = inst_type.capitalize() + " Status: " else: name = "" deleted_label = "" if getattr(inst, 'deleted', False): deleted_label = '<span class="label label-danger">Deleted</span>' return '%s\n<span class="%s">%s%s</span>' % (deleted_label, label_cls, name, state)
def details_url(inst, target): """Get a url for the details of an instance's field.""" # Get instance type and import the appropriate utilities module. inst_type = utils.get_type_from_instance(inst) mod = import_module("synnefo_admin.admin.resources.{}s.utils".format(inst_type)) # Call the details_href function for the provided target. func = getattr(mod, "get_{}_details_href".format(target), None) if func: return func(inst) else: raise Exception("Wrong target name: {}".format(target))
def details_url(inst, target): """Get a url for the details of an instance's field.""" # Get instance type and import the appropriate utilities module. inst_type = utils.get_type_from_instance(inst) mod = import_module("synnefo_admin.admin.resources.{}s.utils".format(inst_type)) # Call the details_href function for the provided target. func = getattr(mod, "get_{}_details_href".format(target), None) if func: return func(inst) else: raise Exception("Wrong target name: {}".format(target))