From 37c95d966e3037d0d1cfada17e46105c4114b05d Mon Sep 17 00:00:00 2001
From: Eugene Burmakin
Date: Fri, 2 May 2025 20:05:12 +0200
Subject: [PATCH] Remove sample points
---
.gitignore | 2 ++
CHANGELOG.md | 6 ++++++
app/models/user.rb | 20 -------------------
.../devise/registrations/_api_key.html.erb | 18 ++++++-----------
app/views/settings/_navigation.html.erb | 3 ---
app/views/shared/_navbar.html.erb | 4 ++++
spec/models/user_spec.rb | 20 -------------------
7 files changed, 18 insertions(+), 55 deletions(-)
diff --git a/.gitignore b/.gitignore
index 3e2a87f6..c5df6beb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -68,5 +68,7 @@
/config/credentials/production.key
/config/credentials/production.yml.enc
+/config/credentials/staging.key
+/config/credentials/staging.yml.enc
Makefile
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c01862a..225bb287 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+# 0.25.9 - UNRELEASED
+
+## Removed
+
+- Sample points are no longer being imported automatically for new users.
+
# 0.25.8 - 2025-04-24
## Fixed
diff --git a/app/models/user.rb b/app/models/user.rb
index 8d7282b4..e9c072e1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -16,7 +16,6 @@ class User < ApplicationRecord
has_many :trips, dependent: :destroy
after_create :create_api_key
- after_create :import_sample_points
after_commit :activate, on: :create, if: -> { DawarichSettings.self_hosted? }
before_save :sanitize_input
@@ -134,23 +133,4 @@ class User < ApplicationRecord
settings['photoprism_url']&.gsub!(%r{/+\z}, '')
settings.try(:[], 'maps')&.try(:[], 'url')&.strip!
end
-
- # rubocop:disable Metrics/MethodLength
- def import_sample_points
- return unless Rails.env.development? ||
- Rails.env.production? ||
- (Rails.env.test? && ENV['IMPORT_SAMPLE_POINTS'])
-
- import = imports.create(
- name: 'DELETE_ME_this_is_a_demo_import_DELETE_ME',
- source: 'gpx'
- )
-
- import.file.attach(
- Rack::Test::UploadedFile.new(
- Rails.root.join('lib/assets/sample_points.gpx'), 'application/xml'
- )
- )
- end
- # rubocop:enable Metrics/MethodLength
end
diff --git a/app/views/devise/registrations/_api_key.html.erb b/app/views/devise/registrations/_api_key.html.erb
index c6c9f0d0..64fb732c 100644
--- a/app/views/devise/registrations/_api_key.html.erb
+++ b/app/views/devise/registrations/_api_key.html.erb
@@ -4,21 +4,15 @@
Docs: <%= link_to "API documentation", '/api-docs', class: 'underline hover:no-underline' %>
- Usage example:
+ Usage examples
-
-
-
-
<%= api_v1_owntracks_points_url(api_key: current_user.api_key) %>
-
+
OwnTracks
+
<%= api_v1_owntracks_points_url(api_key: current_user.api_key) %>
-
-
-
<%= api_v1_overland_batches_url(api_key: current_user.api_key) %>
-
-
+ Overland
+ <%= api_v1_overland_batches_url(api_key: current_user.api_key) %>
- <%= link_to "Generate new API key", generate_api_key_path, data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?", turbo_method: :post }, class: 'btn btn-primary' %>
+ <%= link_to "Generate new API key", generate_api_key_path, data: { confirm: "Are you sure? This will invalidate the current API key.", turbo_confirm: "Are you sure?", turbo_method: :post }, class: 'btn btn-primary' %>
diff --git a/app/views/settings/_navigation.html.erb b/app/views/settings/_navigation.html.erb
index 4201daed..8b5e51e0 100644
--- a/app/views/settings/_navigation.html.erb
+++ b/app/views/settings/_navigation.html.erb
@@ -5,7 +5,4 @@
<%= link_to 'Background Jobs', settings_background_jobs_path, role: 'tab', class: "tab #{active_tab?(settings_background_jobs_path)}" %>
<% end %>
<%= link_to 'Map', settings_maps_path, role: 'tab', class: "tab #{active_tab?(settings_maps_path)}" %>
- <% if !DawarichSettings.self_hosted? %>
- <%= link_to 'Subscriptions', "#{MANAGER_URL}/auth/dawarich?token=#{current_user.generate_subscription_token}", role: 'tab', class: "tab" %>
- <% end %>
diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb
index fa0c2555..5ed2d096 100644
--- a/app/views/shared/_navbar.html.erb
+++ b/app/views/shared/_navbar.html.erb
@@ -120,6 +120,10 @@
<%= link_to 'Account', edit_user_registration_path %>
<%= link_to 'Settings', settings_path %>
+ <% if !DawarichSettings.self_hosted? %>
+ <%= link_to 'Subscription', "#{MANAGER_URL}/auth/dawarich?token=#{current_user.generate_subscription_token}" %>
+ <% end %>
+
<%= link_to 'Logout', destroy_user_session_path, method: :delete, data: { turbo_method: :delete } %>
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 99aa9f68..1f6b318b 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -56,26 +56,6 @@ RSpec.describe User, type: :model do
end
end
end
-
- describe '#import_sample_points' do
- before do
- ENV['IMPORT_SAMPLE_POINTS'] = 'true'
- end
-
- after do
- ENV['IMPORT_SAMPLE_POINTS'] = nil
- end
-
- it 'creates a sample import and enqueues an import job' do
- user = create(:user)
-
- expect(user.imports.count).to eq(1)
- expect(user.imports.first.name).to eq('DELETE_ME_this_is_a_demo_import_DELETE_ME')
- expect(user.imports.first.source).to eq('gpx')
-
- expect(Import::ProcessJob).to have_been_enqueued.with(user.imports.first.id)
- end
- end
end
describe 'methods' do