mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-31 05:05:18 +01:00
Merge pull request #2255 from ZeiP/feature/#1955_user_tags
#1955: Migrate tags to belong to named users for enhanced privacy.
This commit is contained in:
commit
3ac8702a5e
9 changed files with 130 additions and 24 deletions
|
|
@ -712,9 +712,8 @@ class TodosController < ApplicationController
|
|||
|
||||
|
||||
def tags
|
||||
# TODO: limit to current_user
|
||||
tags_beginning = Tag.where(Tag.arel_table[:name].matches("#{params[:term]}%"))
|
||||
tags_all = Tag.where(Tag.arel_table[:name].matches("%#{params[:term]}%"))
|
||||
tags_beginning = current_user.tags.where(Tag.arel_table[:name].matches("#{params[:term]}%"))
|
||||
tags_all = current_user.tags.where(Tag.arel_table[:name].matches("%#{params[:term]}%"))
|
||||
tags_all = tags_all - tags_beginning
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
|||
|
|
@ -3,13 +3,15 @@ class Tag < ApplicationRecord
|
|||
has_many :taggings
|
||||
has_many :taggable, :through => :taggings
|
||||
|
||||
belongs_to :user
|
||||
|
||||
DELIMITER = ",".freeze # Controls how to split and join tagnames from strings. You may need to change the <tt>validates_format_of parameters</tt> if you change this.
|
||||
JOIN_DELIMITER = ", ".freeze
|
||||
|
||||
# If database speed becomes an issue, you could remove these validations and
|
||||
# rescue the ActiveRecord database constraint errors instead.
|
||||
validates_presence_of :name
|
||||
validates_uniqueness_of :name, :case_sensitive => false
|
||||
validates_uniqueness_of :name, :scope => "user_id", :case_sensitive => false
|
||||
|
||||
before_create :before_create
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
has_many :tags, dependent: :delete_all
|
||||
has_many :notes, -> { order "created_at DESC" }, dependent: :delete_all
|
||||
has_one :preference, dependent: :destroy
|
||||
has_many :attachments, through: :todos
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue