You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: create_contract.rb
    path of file: ./repos/openproject/modules/meeting/app/contracts/meeting_agenda_items
    
    the code of the file until where you have to start completion: #-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2024 the OpenProject GmbH
#
# This program is free software; you can redistribute it an
    
    def user_allowed_to_add
      # when creating a meeting agenda item from the work package tab and not selecting a meeting
      # the meeting and therefore the project is not set
      # in this case we only want to show the "Meeting can't be blank" error instead of a misleading permission base error
      # the error is added by the models presence validation
      return unless visible?

      unless user.allowed_in_project?(:manage_agendas, model.project)
        errors.add :base, :error_unauthorized
      end