Skip to content

Commit 0a37697

Browse files
committed
Prevent assignment of one newsgroup to many categories
Importing & exporting uses newsgroups as primary keys. Only 1:1 Newsgroup -> Category mapping is supported.
1 parent e6d9163 commit 0a37697

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/tasks/discourse_nntp_bridge.rake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ namespace :discourse_nntp_bridge do
2020
begin
2121
print "Newsgroup: "
2222
input = STDIN.gets.strip.downcase
23+
duplicates = CategoryCustomField.where(name: "nntp_bridge_newsgroup", value: input)
24+
if duplicates.count > 0
25+
duplicate_names = "'" + duplicates.map(&:category).map(&:full_slug).join("' and '") + "'"
26+
puts "#{input} is already assigned to #{duplicate_names}"
27+
redo
28+
end
2329
end until newsgroups.include?(input)
2430

2531
CategoryCustomField.create!(

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy