<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def edit_record(self, new_record):
 """ Update a record in AtoM using the provided new_record. The format of new_record is identical to the format returned by get_resource_component_and_children and related methods; consult the documentation for that method in ArchivistsToolkitClient to see the format. This means it's possible, for example, to request a record, modify the returned dict, and pass that dict to this method to update the server. Currently supported fields are: * title * notes * start_date * end_date * date_expression :raises ValueError: if the 'slug' field isn't specified, or no fields to edit were specified. """

        try:
            record_id = new_record["slug"]
        except KeyError:
            raise ValueError("No slug provided!")

        record = self.get_record(record_id)

        field_map = {"title": "title", "level": "levelOfDescription"}
        fields_updated = False
        for field, targetfield in field_map.items():
            try:
                record[targetfield] = new_record[field]
                fields_updated = True
            except KeyError:
                continue

        # Optionally add notes
        if "notes" in new_record and new_record["notes"]:
            note = new_record["notes"][0]
            new_note = {"content": note["content"], "type": note["type"]}
            # This only supports editing a single note, and a single piece of content
            # within that note.
            # If the record already has at least one note, then replace the first note
            # within that record with this one.
            if "notes" not in record or record["notes"] == []:
                record["notes"] = [new_note]
            else:
                record["notes"][0] = new_note

            fields_updated = True
        else:
            # Remove existing notes if the record didn't have a valid note;
            # a note with an empty string as content should be counted as
            # a request to delete the note.
            record["notes"] = []

        # Update date
        updated_date = {}

        # Only single dates are currently supported
        if "dates" in new_record and type(new_record["dates"]) is list:
            new_record["dates"] = new_record["dates"][0]

        # Map agentarchives date specification to AtoM specification
        date_mapping = {
            "start_date": "start_date",
            # 'begin': 'start_date',
            "end_date": "end_date",
            # 'end': 'end_date',
            "date_expression": "date",
        }

        for date_field in date_mapping:
            if date_field in new_record:
                updated_date[date_mapping[date_field]] = new_record[date_field]

        # Add updated date specification to record update
        if updated_date != {}:
            record["dates"] = [updated_date]
            fields_updated = True

        if not fields_updated:
            raise ValueError("No fields to update specified!")

        self._put(
            urljoin(self.base_url, "informationobjects/{}".format(record_id)),
            data=json.dumps(record),
        )