Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
birger
users
Commits
0baeae07
Commit
0baeae07
authored
May 27, 2021
by
o@immerda.ch
Browse files
support for resource quotas
parent
5f81c42a
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/controllers/concerns/api_backend.rb
View file @
0baeae07
...
...
@@ -346,6 +346,10 @@ module ApiBackend
get
([
'resource'
,
'available'
])[
'available'
]
end
def
resource_quota
get
([
'resource'
,
'quota'
])[
'quota'
]
end
def
my_resources
()
get
[
'resource'
,
'mine'
]
end
...
...
app/controllers/resources_controller.rb
View file @
0baeae07
...
...
@@ -18,6 +18,7 @@ class ResourcesController < ApplicationController
def
create
flash
[
:warning
]
=
nil
@resource_names
=
list_of_canonical_resources
@resource_quota
=
api
.
resource_quota
@resource_name
=
params
[
:resource_name
]
@resource_name
=
nil
unless
@resource_names
.
include?
(
@resource_name
)
if
@resource_name
...
...
app/views/application/_menu.html.erb
View file @
0baeae07
...
...
@@ -22,7 +22,7 @@
invites:
({}
if
allow_invites?
),
delete_account:
{},
services:
({
divider:
true
}
if
(
any_resource_enabled?
||
any_resource_exists?
)),
new_resource:
({}
if
feature_toggle?
(
'resource'
)
),
new_resource:
({}),
}.
merge
(
list_of_canonical_resources
.
map
do
|
name
|
if
resource_exists?
(
name
)
...
...
app/views/resources/create.html.erb
View file @
0baeae07
...
...
@@ -15,10 +15,21 @@
<p>
<%
if
@resource_name
&&
!
@disabled
%>
<%
q
=
@resource_quota
[
@resource_name
]
allowed
=
[
q
[
'max'
].
to_i
-
q
[
'cur'
].
to_i
,
0
].
max
%>
<div
class=
"alert"
role=
"alert"
>
<%=
t
(
"
#{
@resource_name
}
_description"
)
%>
<br
/>
<%=
t
(
:quota_msg
,
count:
allowed
)
%>
</div>
<%
if
allowed
>
0
%>
<%=
form_tag
do
%>
<%=
hidden_field_tag
'resource_name'
,
@resource_name
%>
...
...
@@ -37,5 +48,6 @@
<%=
submit_tag
t
(
:create
),
name:
'create'
,
class:
"btn btn-primary"
%>
<%
end
%>
<%
end
%>
<%
end
%>
</p>
config/locales/de.yml
View file @
0baeae07
...
...
@@ -220,6 +220,11 @@ de:
paid
:
bezahlt
bill_thanks
:
"
Wir
danken
dir
sehr
herzlich,
dass
du
im
Jahr
%{year}
%{amount}
an
immerda.ch
gespendet
hast!"
quota_msg
:
zero
:
"
Du
hast
alle
aufgebraucht.
Kontaktiere
uns
wenn
du
mehr
brauchst"
other
:
"
Du
kannst
aktuell
noch
%{count}
neue
erstellen."
one
:
"
Du
kannst
aktuell
noch
eine
neue
erstellen."
activerecord
:
errors
:
messages
:
...
...
config/locales/en.yml
View file @
0baeae07
...
...
@@ -221,6 +221,11 @@ en:
paid
:
paid
bill_thanks
:
"
Thank
you
very
much
for
donating
a
total
of
%{amount}
to
immerda.ch
in
the
year
%{year}!"
quota_msg
:
zero
:
"
You
have
exceeded
you
resources.
Contact
us
if
you
need
more."
one
:
"
You
can
still
create
one."
other
:
"
You
can
still
create
up
to
%{count}
fresh
ones."
activerecord
:
errors
:
messages
:
...
...
Write
Preview
Supports
Markdown
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