Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
immerda
Immerda Apps
users
Commits
0ec426b9
Commit
0ec426b9
authored
Nov 30, 2020
by
o
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow users to create mailman and schleuder lists
parent
2f76a90f
Pipeline
#4746
passed with stages
in 17 minutes and 7 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
2 deletions
+96
-2
app/controllers/concerns/api_backend.rb
app/controllers/concerns/api_backend.rb
+9
-0
app/controllers/resources_controller.rb
app/controllers/resources_controller.rb
+41
-0
app/views/application/_menu.html.erb
app/views/application/_menu.html.erb
+2
-1
app/views/resources/create.html.erb
app/views/resources/create.html.erb
+35
-0
config/locales/de.yml
config/locales/de.yml
+3
-0
config/locales/en.yml
config/locales/en.yml
+3
-0
config/routes.rb
config/routes.rb
+3
-1
No files found.
app/controllers/concerns/api_backend.rb
View file @
0ec426b9
...
...
@@ -344,10 +344,19 @@ module ApiBackend
get
[
'resource'
,
'schema'
],
{
resource_type:
what
}
end
def
resource_user_schema
(
what
)
get
[
'resource'
,
'user_schema'
],
{
resource_type:
what
}
end
def
resource_list
(
what
,
deleted
=
false
)
get
[
'resource'
,
'list'
],
{
resource_type:
what
,
deleted:
deleted
}
end
def
resource_self_create
(
what
,
data
)
post
([
'resource'
,
'self_create'
],
{
resource_type:
what
,
data:
data
})
end
def
resource_create
(
what
,
owner
,
data
)
post
([
'resource'
,
'create'
],
{
resource_type:
what
,
owner:
owner
,
data:
data
})
...
...
app/controllers/resources_controller.rb
View file @
0ec426b9
...
...
@@ -10,4 +10,45 @@ class ResourcesController < ApplicationController
redirect_to
root_path
end
end
def
resource_names
[
'mailman'
,
'schleuder'
]
end
def
create
flash
[
:warning
]
=
nil
@resource_names
=
resource_names
@resource_name
=
params
[
:resource_name
]
@resource_name
=
nil
unless
@resource_names
.
include?
(
@resource_name
)
if
@resource_name
@resource_schema
=
api
.
resource_user_schema
(
@resource_name
)[
'schema'
]
end
if
@resource_name
==
'schleuder'
begin
WkdSrvClient
.
get
(
current_user
)
rescue
@disabled
=
true
flash
[
:warning
]
=
'missing_gpg_key'
end
end
end
def
do_create
@resource_name
=
params
[
:resource_name
]
if
resource_names
.
include?
@resource_name
data
=
{}
params
.
each
do
|
name
,
v
|
if
name
=~
/data_(.*)/
data
[
$1
]
=
v
end
end
@res
=
api
.
resource_self_create
(
@resource_name
,
data
)
flash
[
:success
]
=
:success
end
redirect_to
resources_path
rescue
ApiError
=>
e
flash
[
:danger
]
=
e
.
api_msg
redirect_to
new_resource_path
end
end
app/views/application/_menu.html.erb
View file @
0ec426b9
...
...
@@ -20,7 +20,8 @@
invites:
({}
if
allow_invites?
),
delete_account:
{},
services:
({
divider:
true
}
if
any_resources_enabled?
),
resources:
({}
if
feature_toggle?
(
'resource'
)),
resources:
({
label: :my_resources
}
if
feature_toggle?
(
'resource'
)),
new_resource:
({}
if
feature_toggle?
(
'resource'
)),
jabber:
({
label: :manage_jabber
}
if
resource_enabled?
(
'jabber'
)),
}
%>
<%
end
%>
...
...
app/views/resources/create.html.erb
0 → 100644
View file @
0ec426b9
<nav>
<div
class=
"nav nav-tabs"
id=
"nav-tab"
role=
"tablist"
>
<%
@resource_names
.
each
do
|
pane
|
%>
<a
class=
"nav-item nav-link
<%=
if
pane
==
@resource_name
then
"active"
else
""
end
%>
"
href=
"?resource_name=
<%=
pane
%>
"
role=
"tab"
>
<%=
pane
%>
</a>
<%
end
%>
</div>
</nav>
<p>
<%
if
@resource_name
&&
!
@disabled
%>
<%=
form_tag
do
%>
<%=
hidden_field_tag
'resource_name'
,
@resource_name
%>
<%
@resource_schema
.
each
do
|
n
,
v
|
%>
<div
class=
"form-group"
>
<%=
label_tag
n
%>
<%=
case
v
when
'text'
text_field_tag
(
'data_'
+
n
,
""
,
class:
'form-control'
)
when
Array
select_tag
(
'data_'
+
n
,
options_for_select
(
v
),
class:
'form-control'
)
end
%>
</div>
<%
end
%>
<%=
submit_tag
t
(
:create
),
name:
'create'
,
class:
"btn btn-primary"
%>
<%
end
%>
<%
end
%>
</p>
config/locales/de.yml
View file @
0ec426b9
...
...
@@ -195,6 +195,9 @@ de:
invite_token
:
one
:
"
Einladungscode"
other
:
"
Einladungscodes"
my_resources
:
"
Liste
meiner
Zusatzdienste"
new_resource
:
"
Dienst
erstellen"
missing_gpg_key
:
"
Hierfür
wird
ein
gpg
key
benötigt.
Bitte
lade
einen
unter
dem
Punkt
OpenPGP
Schlüssel
hoch."
activerecord
:
...
...
config/locales/en.yml
View file @
0ec426b9
...
...
@@ -196,6 +196,9 @@ en:
invite_token
:
one
:
"
Invite
Code"
other
:
"
Invite
Codes"
my_resources
:
"
List
my
extra
services"
new_resource
:
"
Create
service"
missing_gpg_key
:
"
GPG
Key
needed.
Please
upload
one
in
the
OpenPGP
Keys
settings."
activerecord
:
...
...
config/routes.rb
View file @
0ec426b9
...
...
@@ -65,7 +65,9 @@ Rails.application.routes.draw do
get
'/msg'
,
to:
'application#msg'
get
'/resources'
,
to:
'resources#show'
get
'/resources'
,
to:
'resources#show'
get
'/new_resource'
,
to:
'resources#create'
post
'/new_resource'
,
to:
'resources#do_create'
else
root
to:
'admin#index'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment