Example #1
0
def list_charge_type():
    items = api.list(ChargeType, False)
    
    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("charge_type/list.html", items=items)
Example #2
0
def list_weather():
    items = api.list(WeatherCondition, False)

    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("weather/list.html", items=items)
Example #3
0
def list_event_role():
    items = api.list(EventRole, False)

    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("event_role/list.html", items=items)
Example #4
0
def list_location():
    items = api.list(EventLocation, False)

    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("location/list.html", items=items)
Example #5
0
def list_user():
    items = api.list(User, False)

    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("user/list.html", items=items)
Example #6
0
def list_partnership():
    items = api.list(Partnership, False)
    
    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("partnership/list.html", items=items)
Example #7
0
def view_event(id):
    item = api.get(Event, id)

    if not item:
        Alert.bad("Could not find <strong>Event</strong> {}".format(id))
        return redirect("/events/")

    data = {"id": id, "name": item.name, "description": item.description}

    return render_template("event/view.html", **data)
Example #8
0
def delete_location(id):
    item = api.get(EventLocation, id)

    if not item:
        Alert.bad("Could not find <strong>Location</strong> {}".format(id))
        return redirect("/locations/")

    data = {"id": id, "name": item.name, "description": item.description}

    return render_template("location/delete.html", **data)
Example #9
0
def delete_event_role(id):
    item = api.get(EventRole, id)

    if not item:
        Alert.bad("Could not find <strong>Event Role</strong> {}".format(id))
        return redirect("/eventroles/")

    data = {"id": id, "name": item.name, "description": item.description}

    return render_template("event_role/delete.html", **data)
Example #10
0
def delete_weather(id):
    item = api.get(WeatherCondition, id)

    if not item:
        Alert.bad(
            "Could not find <strong>Weather Condition</strong> {}".format(id))
        return redirect("/weather/")

    data = {"id": id, "name": item.name, "description": item.description}

    return render_template("weather/delete.html", **data)
Example #11
0
def delete_charge_type(id):
    item = api.get(ChargeType, id)
    
    if not item:
        Alert.bad("Could not find <strong>Charge Type</strong> {}".format(id))
        return redirect("/chargetypes/")
    
    data = {
        "id": id,
        "name": item.name,
        "description": item.description
    }

    return render_template("charge_type/delete.html", **data) 
Example #12
0
def delete_partnership(id):
    item = api.get(Partnership, id)
    
    if not item:
        Alert.bad("Could not find <strong>Partnership</strong> {}".format(id))
        return redirect("/partnerships/")
    
    data = {
        "id": id,
        "name": item.name,
        "description": item.description
    }

    return render_template("partnership/delete.html", **data) 
Example #13
0
def restore_event(id):
    item = api.get(Event, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/events/")

    restored = api.restore(Event, item)

    if not restored:
        Alert.bad(api.error)
        return redirect("/events/")

    Alert.good("Restored <strong>Event</strong> with name <strong>{}</strong>".format(item.name))
    return redirect("/events/")
Example #14
0
def restore_location(id):
    item = api.get(EventLocation, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/locations/")

    restored = api.restore(EventLocation, item)

    if not restored:
        Alert.bad(api.error)
        return redirect("/locations/")

    Alert.good("Restored <strong>Location</strong> with name <strong>{}</strong>".format(item.name))
    return redirect("/locations/")
Example #15
0
def delete_location_post(id):
    item = api.get(EventLocation, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/locations/")

    deleted = api.delete(EventLocation, item)

    if not deleted:
        Alert.bad(api.error)
        return redirect("/locations/{}/".format(id))

    Alert.good("Deleted <strong>Location</strong> '{}'".format(item.name))
    return redirect("/locations/")
Example #16
0
def delete_user_post(id):
    item = api.get(User, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/users/")

    deleted = api.delete(User, item)

    if not deleted:
        Alert.bad(api.error)
        return redirect("/users/{}/".format(id))

    Alert.good("Deleted <strong>User</strong> '{}'".format(item.name))
    return redirect("/users/")
Example #17
0
def delete_partnership_post(id):
    item = api.get(Partnership, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/partnerships/")

    deleted = api.delete(Partnership, item)

    if not deleted:
        Alert.bad(api.error)
        return redirect("/partnerships/{}/".format(id))

    Alert.good("Deleted <strong>Partnership</strong> '{}'".format(item.name))
    return redirect("/partnerships/")
Example #18
0
def restore_partnership(id):
    item = api.get(Partnership, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/partnerships/")

    restored = api.restore(Partnership, item)

    if not restored:
        Alert.bad(api.error)
        return redirect("/partnerships/")

    Alert.good("Restored <strong>Partnership</strong> with name <strong>{}</strong>".format(item.name))
    return redirect("/partnerships/")
Example #19
0
def delete_charge_type_post(id):
    item = api.get(ChargeType, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/chargetypes/")

    deleted = api.delete(ChargeType, item)

    if not deleted:
        Alert.bad(api.error)
        return redirect("/chargetypes/{}/".format(id))

    Alert.good("Deleted <strong>Charge Type</strong> '{}'".format(item.name))
    return redirect("/chargetypes/")
Example #20
0
def delete_event_role_post(id):
    item = api.get(EventRole, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/eventroles/")

    deleted = api.delete(EventRole, item)

    if not deleted:
        Alert.bad(api.error)
        return redirect("/eventroles/{}/".format(id))

    Alert.good("Deleted <strong>Event Role</strong> '{}'".format(item.name))
    return redirect("/eventroles/")
Example #21
0
def restore_charge_type(id):
    item = api.get(ChargeType, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/chargetypes/")

    restored = api.restore(ChargeType, item)

    if not restored:
        Alert.bad(api.error)
        return redirect("/chargetypes/")

    Alert.good("Restored <strong>Charge Type</strong> with name <strong>{}</strong>".format(item.name))
    return redirect("/chargetypes/")
Example #22
0
def delete_weather_post(id):
    item = api.get(WeatherCondition, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/weather/")

    deleted = api.delete(WeatherCondition, item)

    if not deleted:
        Alert.bad(api.error)
        return redirect("/weather/{}/".format(id))

    Alert.good("Deleted <strong>Weather Condition</strong> '{}'".format(
        item.name))
    return redirect("/weather/")
Example #23
0
def restore_user(id):
    item = api.get(User, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/users/")

    restored = api.restore(User, item)

    if not restored:
        Alert.bad(api.error)
        return redirect("/users/")

    Alert.good(
        "Restored <strong>User</strong> with name <strong>{}</strong>".format(
            item.name))
    return redirect("/users/")
Example #24
0
def restore_weather(id):
    item = api.get(WeatherCondition, id)

    if not item:
        Alert.bad(api.error)
        return redirect("/weather/")

    restored = api.restore(WeatherCondition, item)

    if not restored:
        Alert.bad(api.error)
        return redirect("/weather/")

    Alert.good(
        "Restored <strong>Weather Condition</strong> with name <strong>{}</strong>"
        .format(item.name))
    return redirect("/weather/")
Example #25
0
def view_event_type(id):
    item = api.get(EventType, id)
    
    if not item:
        Alert.bad("Could not find <strong>Event Type</strong> {}".format(id))
        return redirect("/eventtypes/")
    
    charge_types = api.list(ChargeType)

    data = {
        "id": id,
        "name": item.name,
        "description": item.description,
        "charge_types": charge_types,
        "defaultchargetype": item.default_charge_type_id
    }

    return render_template("event_type/view.html", **data)
Example #26
0
def init():
    import os

    try:
        generate_controller(ChargeType, "Charge Type", "charge_type",
                            "chargetypes", "charge_type.gen.py")
        generate_controller(Partnership, "Partnership", "partnership",
                            "partnerships", "partnership.gen.py")
        generate_controller(EventType, "Event Type", "event_type",
                            "eventtypes", "event_type.gen.py")
        generate_controller(EventRole, "Event Role", "event_role",
                            "eventroles", "event_role.gen.py")
        generate_controller(EventLocation, "Location", "location", "locations",
                            "locations.gen.py")
        generate_controller(Event, "Event", "event", "events", "events.gen.py")
    except Exception as e:
        Alert.bad(str(e))

    return redirect("/")
Example #27
0
def view_event(id):
    item = api.get(Event, id)

    charge_types = api.list(ChargeType)
    locations = api.list(EventLocation)
    event_types = api.list(EventType)
    
    if not item:
        Alert.bad("Could not find <strong>Event</strong> {}".format(id))
        return redirect("/events/")
    
    data = {
        "id": id,
        "name": item.name,
        "description": item.description,
        "event_types": event_types,
        "charge_types": charge_types,
        "locations": locations
    }

    return render_template("event/view.html", **data)
Example #28
0
def update_charge_type(id):
    data = {
        "name": querystring_get("name"),
        "description": querystring_get("description")
    }

    if not data["name"]:
        Alert.bad("The <strong>name</strong> field is required")
        return render_template("charge_type/view.html", **data)

    create = str(id).lower() == "create"

    item = None
    if create:
        item = ChargeType()
    else:   
        item = api.get(ChargeType, id)
        if not item:
            Alert.bad("Could not find <strong>Charge Type</strong> {}; {}".format(id, api.error))
            return render_template("charge_type/view.html", **data)

    item.name = data["name"]
    item.description = data["description"]
    item = api.update(ChargeType, item)
    
    if not item:
        Alert.bad(api.error)
        return render_template("charge_type/view.html", **data)
    
    Alert.good("Charge Type <strong>{}</strong> {}".format(item.name, "created" if create else "updated"))
    return redirect("/chargetypes/{}".format(item.id))
Example #29
0
def view_user(id):
    item = api.get(User, id)

    if not item:
        Alert.bad("Could not find <strong>User</strong> {}".format(id))
        return redirect("/users/")

    data = {
        "id": id,
        "username": item.username,
        "forename": item.forename,
        "surname": item.surname,
        "email": item.email_address,
        "dob": item.dob,
        "address1": item.address.line1,
        "address2": item.address.line2,
        "address3": item.address.line3,
        "county": item.address.county,
        "postcode": item.address.postcode
    }

    return render_template("user/view.html", **data)
Example #30
0
def view_location(id):
    item = api.get(EventLocation, id)

    if not item:
        Alert.bad("Could not find <strong>Location</strong> {}".format(id))
        return redirect("/locations/")

    data = {
        "id": id,
        "name": item.name,
        "description": item.description,
        "address1": item.address.line1 if item.address else "",
        "address2": item.address.line2 if item.address else "",
        "address3": item.address.line3 if item.address else "",
        "county": item.address.county if item.address else "",
        "postcode": item.address.postcode if item.address else "",
        "contactname": item.contact_name,
        "contactemail": item.contact_email_address,
        "contactphone1": item.contact_telephone1,
        "contactphone2": item.contact_telephone2
    }

    return render_template("location/view.html", **data)