def post(self, resource_id = None):
        data = request.get_json()
        verify_request_contains_mandatory_fields(data, self.mandatory_fields)

        # Resource id might also be part of the incoming json.
        resource_uri = None
        if not resource_id:
            resource_uri = data["resource_uri"]

        resource = self.get_resource_with_id_or_uri(resource_id, resource_uri)

        start_date, end_date = self.parse_date_range_from_dict(data)

        start_time = parse_time(data["start_time"])
        end_time = parse_time(data["end_time"])
        week_day = data["week_day"]
        if data["note"]:
            note = data["note"]
            if not (len(note) <= 50):
                abort(400, __error__=[u'Maks lengde for merknad er 50 tegn'])
        else:
            note= ""


        self.validate_start_and_end_times(start_date, end_date, start_time, end_time)

        # Check that the time has correct minute interval, only 30-minute intervals allowed
        invalid_minutes = filter(lambda my_time: my_time.minute not in [0, 30], [start_time, end_time])
        if invalid_minutes:
            abort(400,
                  __error__=[u'Tidene må angis i hele halvtimer']
            )

        weekly_blocked_time = WeeklyBlockedTime(resource, week_day,
            start_date, end_date, start_time, end_time, note)
        ensure(POST, weekly_blocked_time)

        if self.is_conflict_slot_time(resource, start_date, end_date, week_day, start_time, end_time) or \
                self.is_conflict_rammetid(resource, start_date, end_date, week_day, start_time, end_time):
            abort(
                400,
                __error__=[u'Tiden er ikke tilgjengelig for blokkering']
            )       
        if self.is_conflict_blocked_time(resource, start_date, end_date, week_day, start_time, end_time):
            abort(
                400,
                __error__=[u'Tiden er allerede blokkert']
            )                 

        current_app.db_session.add(weekly_blocked_time)
        current_app.db_session.commit()
        current_app.db_session.refresh(weekly_blocked_time)

        return marshal(weekly_blocked_time, self.fields), 201
    def put(self, resource_id=None, resource_uri=None):
        data = request.get_json()

        mandatory_fields = ["auto_approval_allowed", "single_booking_allowed",
                            "repeating_booking_allowed"]
        verify_request_contains_mandatory_fields(data, mandatory_fields)

        resource = self.get_resource(resource_id, resource_uri)
        ensure(PUT, resource)
        # Update the allowed booking types..
        resource.auto_approval_allowed = data["auto_approval_allowed"]
        resource.single_booking_allowed = data["single_booking_allowed"]
        resource.repeating_booking_allowed = data["repeating_booking_allowed"]

        current_app.db_session.add(resource)
        current_app.db_session.commit()
        current_app.db_session.refresh(resource)
        return resource