]> git.openstreetmap.org Git - rails.git/commitdiff
Merge pull request #3676 from harry-wood/notes-disappear-time
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 23 Nov 2022 15:44:26 +0000 (15:44 +0000)
committerGitHub <noreply@github.com>
Wed, 23 Nov 2022 15:44:26 +0000 (15:44 +0000)
Display how long until a note will disappear

1  2 
app/controllers/api/notes_controller.rb
app/views/browse/note.html.erb
config/locales/en.yml

index 5e24aa7858ddf1c70b6106baee616a7ce385b1eb,4d49774bad2f734a69f39b986b7d15647a563466..5e24532e79bf7f31594a82db9143465aa502dcbf
@@@ -9,7 -9,6 +9,7 @@@ module Ap
  
      before_action :set_locale
      around_action :api_call_handle_error, :api_call_timeout
 +    before_action :set_request_formats, :except => [:feed]
  
      ##
      # Return a list of notes in a given area
  
        # Check the the bounding box is not too big
        bbox.check_size(Settings.max_note_request_area)
 +      @min_lon = bbox.min_lon
 +      @min_lat = bbox.min_lat
 +      @max_lon = bbox.max_lon
 +      @max_lat = bbox.max_lat
  
        # Find the notes we want to return
        @notes = notes.bbox(bbox).order("updated_at DESC").limit(result_limit).preload(:comments)
        end
      end
  
 +    ##
 +    # Read a note
 +    def show
 +      # Check the arguments are sane
 +      raise OSM::APIBadUserInput, "No id was given" unless params[:id]
 +
 +      # Find the note and check it is valid
 +      @note = Note.find(params[:id])
 +      raise OSM::APINotFoundError unless @note
 +      raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? || current_user&.moderator?
 +
 +      # Render the result
 +      respond_to do |format|
 +        format.xml
 +        format.rss
 +        format.json
 +        format.gpx
 +      end
 +    end
 +
      ##
      # Create a new note
      def create
        end
      end
  
 +    ##
 +    # Delete (hide) a note
 +    def destroy
 +      # Check the arguments are sane
 +      raise OSM::APIBadUserInput, "No id was given" unless params[:id]
 +
 +      # Extract the arguments
 +      id = params[:id].to_i
 +      comment = params[:text]
 +
 +      # Find the note and check it is valid
 +      @note = Note.find(id)
 +      raise OSM::APINotFoundError unless @note
 +      raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
 +
 +      # Mark the note as hidden
 +      Note.transaction do
 +        @note.status = "hidden"
 +        @note.save
 +
 +        add_comment(@note, comment, "hidden", :notify => false)
 +      end
 +
 +      # Return a copy of the updated note
 +      respond_to do |format|
 +        format.xml { render :action => :show }
 +        format.json { render :action => :show }
 +      end
 +    end
 +
      ##
      # Add a comment to an existing note
      def comment
          bbox.check_size(Settings.max_note_request_area)
  
          notes = notes.bbox(bbox)
 +        @min_lon = bbox.min_lon
 +        @min_lat = bbox.min_lat
 +        @max_lon = bbox.max_lon
 +        @max_lat = bbox.max_lat
        end
  
        # Find the comments we want to return
        end
      end
  
 -    ##
 -    # Read a note
 -    def show
 -      # Check the arguments are sane
 -      raise OSM::APIBadUserInput, "No id was given" unless params[:id]
 -
 -      # Find the note and check it is valid
 -      @note = Note.find(params[:id])
 -      raise OSM::APINotFoundError unless @note
 -      raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? || current_user&.moderator?
 -
 -      # Render the result
 -      respond_to do |format|
 -        format.xml
 -        format.rss
 -        format.json
 -        format.gpx
 -      end
 -    end
 -
 -    ##
 -    # Delete (hide) a note
 -    def destroy
 -      # Check the arguments are sane
 -      raise OSM::APIBadUserInput, "No id was given" unless params[:id]
 -
 -      # Extract the arguments
 -      id = params[:id].to_i
 -      comment = params[:text]
 -
 -      # Find the note and check it is valid
 -      @note = Note.find(id)
 -      raise OSM::APINotFoundError unless @note
 -      raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
 -
 -      # Mark the note as hidden
 -      Note.transaction do
 -        @note.status = "hidden"
 -        @note.save
 -
 -        add_comment(@note, comment, "hidden", :notify => false)
 -      end
 -
 -      # Return a copy of the updated note
 -      respond_to do |format|
 -        format.xml { render :action => :show }
 -        format.json { render :action => :show }
 -      end
 -    end
 -
      ##
      # Return a list of notes matching a given string
      def search
      # on their status and the user's request parameters
      def closed_condition(notes)
        closed_since = if params[:closed]
-                        params[:closed].to_i
+                        params[:closed].to_i.days
                       else
-                        7
+                        Note::DEFAULT_FRESHLY_CLOSED_LIMIT
                       end
  
        if closed_since.negative?
        elsif closed_since.positive?
          notes.where(:status => "open")
               .or(notes.where(:status => "closed")
-                       .where(notes.arel_table[:closed_at].gt(Time.now.utc - closed_since.days)))
+                       .where(notes.arel_table[:closed_at].gt(Time.now.utc - closed_since)))
        else
          notes.where(:status => "open")
        end
index 1181e0b034f0caadb2c0dd7201673100f1f7dab7,29c5ca3e15539654e327e859d43002cc2f6250b6..a814d8c8b13a8dc44ec68aa59b5ff6ce003523a6
          </div>
          <div class="btn-wrapper">
            <% if current_user.moderator? -%>
 -            <input type="submit" name="hide" value="<%= t("javascripts.notes.show.hide") %>" class="btn btn-light" data-note-id="<%= @note.id %>" data-method="DELETE" data-url="<%= note_url(@note, "json") %>">
 +            <input type="submit" name="hide" value="<%= t("javascripts.notes.show.hide") %>" class="btn btn-light" data-method="DELETE" data-url="<%= note_url(@note, "json") %>">
            <% end -%>
 -          <input type="submit" name="close" value="<%= t("javascripts.notes.show.resolve") %>" class="btn btn-primary" data-note-id="<%= @note.id %>" data-method="POST" data-url="<%= close_note_url(@note, "json") %>">
 -          <input type="submit" name="comment" value="<%= t("javascripts.notes.show.comment") %>" class="btn btn-primary" data-note-id="<%= @note.id %>" data-method="POST" data-url="<%= comment_note_url(@note, "json") %>" disabled="1">
 +          <input type="submit" name="close" value="<%= t("javascripts.notes.show.resolve") %>" class="btn btn-primary" data-method="POST" data-url="<%= close_note_url(@note, "json") %>">
 +          <input type="submit" name="comment" value="<%= t("javascripts.notes.show.comment") %>" class="btn btn-primary" data-method="POST" data-url="<%= comment_note_url(@note, "json") %>" disabled="1">
          </div>
        </form>
      <% end -%>
      <form class="mb-3" action="#">
        <input type="hidden" name="text" value="" autocomplete="off">
        <div class="btn-wrapper">
 -        <% if current_user and current_user.moderator? -%>
 -          <input type="submit" name="hide" value="<%= t("javascripts.notes.show.hide") %>" class="btn btn-light" data-note-id="<%= @note.id %>" data-method="DELETE" data-url="<%= note_url(@note, "json") %>">
 +        <% if @note.status != "hidden" and current_user and current_user.moderator? -%>
 +          <input type="submit" name="hide" value="<%= t("javascripts.notes.show.hide") %>" class="btn btn-light" data-method="DELETE" data-url="<%= note_url(@note, "json") %>">
          <% end -%>
          <% if current_user -%>
 -          <input type="submit" name="reopen" value="<%= t("javascripts.notes.show.reactivate") %>" class="btn btn-primary" data-note-id="<%= @note.id %>" data-method="POST" data-url="<%= reopen_note_url(@note, "json") %>">
 +          <input type="submit" name="reopen" value="<%= t("javascripts.notes.show.reactivate") %>" class="btn btn-primary" data-method="POST" data-url="<%= reopen_note_url(@note, "json") %>">
          <% end -%>
        </div>
      </form>
    <% end %>
  
    <% if current_user && current_user != @note.author %>
-     <p><small class="text-muted"><%= t "javascripts.notes.show.report_link_html", :link => report_link(t(".report"), @note) %></small></p>
+     <p>
+       <small class="text-muted">
+         <%= t "javascripts.notes.show.report_link_html", :link => report_link(t(".report"), @note) %>
+         <% if @note.status == "open" %>
+           <%= t "javascripts.notes.show.other_problems_resolve", :link => report_link(t(".report"), @note) %>
+         <% elsif @note.status == "closed" %>
+           <%= t "javascripts.notes.show.other_problems_resolved" %>
+         <% end %>
+       </small>
+     </p>
+   <% end %>
+   <% if @note.freshly_closed? %>
+     <small class="text-muted">
+       <%= t "javascripts.notes.show.disappear_date_html", :disappear_in => disappear_in(@note) %>
+     </small>
    <% end %>
  </div>
diff --combined config/locales/en.yml
index 6a32e29a2ac0de6be7cddf8e6ff6b3ea7201756b,c7664c83c7cb28fc6c9b0d989fa1d286da2b00d1..e05dfd8d03ede1c7f48cd01be575e7f34627ccd0
@@@ -405,7 -405,6 +405,7 @@@ en
        wikimedia_commons_link: "The %{page} item on Wikimedia Commons"
        telephone_link: "Call %{phone_number}"
        colour_preview: "Colour %{colour_value} preview"
 +      email_link: "Email %{email}"
      note:
        title: "Note: %{id}"
        new_note: "New Note"
      index:
        title: "Changesets"
        title_user: "Changesets by %{user}"
 +      title_user_link_html: "Changesets by %{user_link}"
        title_friend: "Changesets by my friends"
        title_nearby: "Changesets by nearby users"
        empty: "No changesets found."
      help: Help
      about: About
      copyright: Copyright
 +    communities: Communities
      community: Community
      community_blogs: "Community Blogs"
      community_blogs_title: "Blogs from members of the OpenStreetMap community"
        create account minute: Create an account. It only takes a minute.
        no account: Don't have an account?
        account not active: "Sorry, your account is not active yet.<br />Please use the link in the account confirmation email to activate your account, or <a href=\"%{reconfirm}\">request a new confirmation email</a>."
 -      account is suspended: Sorry, your account has been suspended due to suspicious activity.<br />Please contact <a href="%{webmaster}">support</a> if you wish to discuss this.
        auth failure: "Sorry, could not log in with those details."
        openid_logo_alt: "Log in with an OpenID"
        auth_providers:
        title: "Logout"
        heading: "Logout from OpenStreetMap"
        logout_button: "Logout"
 +    suspended_flash:
 +      suspended: Sorry, your account has been suspended due to suspicious activity.
 +      contact_support_html: Please contact %{support_link} if you wish to discuss this.
 +      support: support
    shared:
      markdown_help:
        title_html: Parsed with <a href="https://kramdown.gettalong.org/quickref.html">kramdown</a>
              <li>Make clear that the data is available under the Open Database License.</li>
            </ul>
          credit_3_1_html: |
 -         For the copyright notice, we have different requirements on how this should be 
 -         displayed, depending on how you are using our data. For example, different 
 -         rules apply on how to show the copyright notice depending on whether you have 
 -         created a browsable map, a printed map or a static image. Full details on the 
 -         requirements can be found in the 
 -         <a href="https://wiki.osmfoundation.org/wiki/Licence/Attribution_Guidelines">Attribution 
 -         Guidelines</a>. 
 +         For the copyright notice, we have different requirements on how this should be
 +         displayed, depending on how you are using our data. For example, different
 +         rules apply on how to show the copyright notice depending on whether you have
 +         created a browsable map, a printed map or a static image. Full details on the
 +         requirements can be found in the
 +         <a href="https://wiki.osmfoundation.org/wiki/Licence/Attribution_Guidelines">Attribution
 +         Guidelines</a>.
          credit_4_html: |
            To make clear that the data is available under the Open
            Database License, you may link to
            Just go to <a href='%{map_url}'>the map</a> and click the note icon:
            <span class='icon note'></span>. This will add a marker to the map, which you can move
            by dragging. Add your message, then click save, and other mappers will investigate.
 +    communities:
 +      title: Communities
 +      lede_text: |
 +        People from all over the world contribute to or use OpenStreetMap.
 +        While many participate as individuals, others have formed communities.
 +        These groups come in a range of sizes and represent geographies from small towns to large multi-country regions.
 +        They can also be formal or informal.
 +      local_chapters:
 +        title: Local Chapters
 +        about_text: |
 +          Local Chapters are country-level or region-level groups that have taken the formal step of
 +          establishing not-for-profit legal entities. They represent the area's map and mappers when
 +          dealing with local government, business, and media. They have also formed an affiliation
 +          with the OpenStreetMap Foundation (OSMF), giving them a link to the legal and copyright
 +          governing body.
 +        list_text: |
 +          The following communities are formally established as Local Chapters:
 +      other_groups:
 +        title: Other Groups
 +        about_html: |
 +          There is no need to formally establish a group to the same extent as the Local Chapters.
 +          Indeed many groups exist very sucessfully as an informal gathering of people or as a
 +          community group. Anyone can set up or join these. Read more on the
 +          <a href="https://wiki.openstreetmap.org/wiki/User_group">Communities wiki page</a>.
    traces:
      visibility:
        private: "Private (only shared as anonymous, unordered points)"
          reactivate: Reactivate
          comment_and_resolve: Comment & Resolve
          comment: Comment
-         report_link_html: "If this note contains sensitive information that needs to be removed, you can %{link}. For all other problems with the note, please resolve it yourself with a comment."
+         report_link_html: "If this note contains sensitive information that needs to be removed, you can %{link}."
+         other_problems_resolve: "For all other problems with the note, please resolve it yourself with a comment."
+         other_problems_resolved: "For all other problems, resolving is sufficient."
+         disappear_date_html: "This resolved note will disappear from the map in %{disappear_in}."
      edit_help: Move the map and zoom in on a location you want to edit, then click here.
      directions:
        ascend: "Ascend"