Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 471
- Log:
Add 'quick and dirty' blacklist mechanism
- Author:
- rool
- Date:
- Sat Jan 26 09:02:22 +0000 2019
- Size:
- 1665 Bytes
1 | # 2019-01-26 (ADH): |
2 | # |
3 | # Very simplistic quick-and-dirty implementation; Blacklist has just one |
4 | # row, which contains a text field of newline separated items processed |
5 | # by Ruby when checking a post. Not efficient but sufficient for now. |
6 | # |
7 | class BlacklistController < ApplicationController |
8 | @@hubssolib_permissions = HubSsoLib::Permissions.new({ |
9 | :new => [ :admin, :webmaster ], |
10 | :create => [ :admin, :webmaster ], |
11 | :edit => [ :admin, :webmaster ], |
12 | :update => [ :admin, :webmaster ], |
13 | :destroy => [ :admin, :webmaster ], |
14 | }) |
15 | |
16 | public |
17 | |
18 | def BlacklistController.hubssolib_permissions |
19 | @@hubssolib_permissions |
20 | end |
21 | |
22 | def show |
23 | @blacklist = Blacklist.find( :first ) |
24 | end |
25 | |
26 | def new |
27 | @blacklist = Blacklist.new |
28 | end |
29 | |
30 | def create |
31 | set_list_to( params[ :blacklist ][ :list ] ) |
32 | flash[ :notice ] = 'Blacklist created' |
33 | redirect_to( blacklist_path() ) |
34 | end |
35 | |
36 | def edit |
37 | @blacklist = Blacklist.find( :first ) |
38 | end |
39 | |
40 | def update |
41 | set_list_to( params[ :blacklist ][ :list ] ) |
42 | flash[ :notice ] = 'Blacklist updated' |
43 | redirect_to( blacklist_path() ) |
44 | end |
45 | |
46 | def destroy |
47 | set_list_to( '' ) |
48 | flash[ :notice ] = 'Blacklist emptied' |
49 | redirect_to( blacklist_path() ) |
50 | end |
51 | |
52 | private |
53 | |
54 | def set_list_to( list ) |
55 | blacklist = if Blacklist.count > 0 |
56 | Blacklist.find(:first) |
57 | else |
58 | Blacklist.new |
59 | end |
60 | |
61 | blacklist.list = list || '' |
62 | blacklist.save! |
63 | end |
64 | |
65 | end |