Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
916865ab
Commit
916865ab
authored
5 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
modify_mailtemplate permission implemented
parent
896bcfc9
No related branches found
No related tags found
1 merge request
!228
Resolve "some permissions should be added"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
smash/web/templates/sidebar.html
+9
-6
9 additions, 6 deletions
smash/web/templates/sidebar.html
smash/web/tests/view/test_mail.py
+10
-1
10 additions, 1 deletion
smash/web/tests/view/test_mail.py
smash/web/views/mails.py
+9
-1
9 additions, 1 deletion
smash/web/views/mails.py
with
28 additions
and
8 deletions
smash/web/templates/sidebar.html
+
9
−
6
View file @
916865ab
...
@@ -73,12 +73,15 @@
...
@@ -73,12 +73,15 @@
</li>
</li>
{% endif %}
{% endif %}
<li
data-desc=
"mail_templates"
>
<a
href=
"{% url 'web.views.mail_templates' %}"
>
{% if "change_mailtemplate" in permissions %}
<i
class=
"fa fa-envelope-o"
></i>
<li
data-desc=
"mail_templates"
>
<span>
Mail templates
</span>
<a
href=
"{% url 'web.views.mail_templates' %}"
>
</a>
<i
class=
"fa fa-envelope-o"
></i>
</li>
<span>
Mail templates
</span>
</a>
</li>
{% endif %}
<li
data-desc=
"export"
>
<li
data-desc=
"export"
>
<a
href=
"{% url 'web.views.export' %}"
>
<a
href=
"{% url 'web.views.export' %}"
>
...
...
This diff is collapsed.
Click to expand it.
smash/web/tests/view/test_mail.py
+
10
−
1
View file @
916865ab
...
@@ -4,8 +4,8 @@ from django.urls import reverse
...
@@ -4,8 +4,8 @@ from django.urls import reverse
from
web.models
import
MailTemplate
from
web.models
import
MailTemplate
from
web.models.constants
import
MAIL_TEMPLATE_CONTEXT_VOUCHER
from
web.models.constants
import
MAIL_TEMPLATE_CONTEXT_VOUCHER
from
web.tests.functions
import
create_voucher
,
get_resource_path
from
web.tests
import
LoggedInTestCase
from
web.tests
import
LoggedInTestCase
from
web.tests.functions
import
create_voucher
,
get_resource_path
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -20,3 +20,12 @@ class MailTests(LoggedInTestCase):
...
@@ -20,3 +20,12 @@ class MailTests(LoggedInTestCase):
page
=
reverse
(
'
web.views.mail_template_generate_for_vouchers
'
)
+
"
?voucher_id=
"
+
str
(
voucher
.
id
)
page
=
reverse
(
'
web.views.mail_template_generate_for_vouchers
'
)
+
"
?voucher_id=
"
+
str
(
voucher
.
id
)
response
=
self
.
client
.
get
(
page
)
response
=
self
.
client
.
get
(
page
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_list_mail_templates
(
self
):
self
.
login_as_admin
()
response
=
self
.
client
.
get
(
reverse
(
"
web.views.mail_templates
"
))
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_list_mail_templates_without_permission
(
self
):
response
=
self
.
client
.
get
(
reverse
(
"
web.views.mail_templates
"
))
self
.
assertEqual
(
response
.
status_code
,
302
)
This diff is collapsed.
Click to expand it.
smash/web/views/mails.py
+
9
−
1
View file @
916865ab
...
@@ -9,6 +9,7 @@ from django.urls import reverse_lazy
...
@@ -9,6 +9,7 @@ from django.urls import reverse_lazy
from
django.views.generic
import
DeleteView
from
django.views.generic
import
DeleteView
from
django.views.generic
import
ListView
from
django.views.generic
import
ListView
from
web.decorators
import
PermissionDecorator
from
web.docx_helper
import
merge_files
from
web.docx_helper
import
merge_files
from
.
import
WrappedView
from
.
import
WrappedView
from
.
import
wrap_response
from
.
import
wrap_response
...
@@ -32,7 +33,11 @@ class MailTemplatesListView(ListView, WrappedView):
...
@@ -32,7 +33,11 @@ class MailTemplatesListView(ListView, WrappedView):
context_object_name
=
"
mail_templates
"
context_object_name
=
"
mail_templates
"
template_name
=
'
mail_templates/list.html
'
template_name
=
'
mail_templates/list.html
'
def
get_context_data
(
self
,
**
kwargs
):
@PermissionDecorator
(
'
change_mailtemplate
'
,
'
mailtemplate
'
)
def
dispatch
(
self
,
*
args
,
**
kwargs
):
return
super
(
MailTemplatesListView
,
self
).
dispatch
(
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
context
=
super
(
MailTemplatesListView
,
self
).
get_context_data
()
context
=
super
(
MailTemplatesListView
,
self
).
get_context_data
()
context
[
'
explanations
'
]
=
{
"
generic
"
:
MailTemplate
.
MAILS_TEMPLATE_GENERIC_TAGS
,
context
[
'
explanations
'
]
=
{
"
generic
"
:
MailTemplate
.
MAILS_TEMPLATE_GENERIC_TAGS
,
"
subject
"
:
MailTemplate
.
MAILS_TEMPLATE_SUBJECT_TAGS
,
"
subject
"
:
MailTemplate
.
MAILS_TEMPLATE_SUBJECT_TAGS
,
...
@@ -43,6 +48,7 @@ class MailTemplatesListView(ListView, WrappedView):
...
@@ -43,6 +48,7 @@ class MailTemplatesListView(ListView, WrappedView):
return
context
return
context
@PermissionDecorator
(
'
change_mailtemplate
'
,
'
mailtemplate
'
)
def
mail_template_add
(
request
):
def
mail_template_add
(
request
):
if
request
.
method
==
'
POST
'
:
if
request
.
method
==
'
POST
'
:
form
=
MailTemplateForm
(
request
.
POST
,
request
.
FILES
)
form
=
MailTemplateForm
(
request
.
POST
,
request
.
FILES
)
...
@@ -59,6 +65,7 @@ def mail_template_add(request):
...
@@ -59,6 +65,7 @@ def mail_template_add(request):
return
wrap_response
(
request
,
'
mail_templates/add.html
'
,
{
'
form
'
:
form
})
return
wrap_response
(
request
,
'
mail_templates/add.html
'
,
{
'
form
'
:
form
})
@PermissionDecorator
(
'
change_mailtemplate
'
,
'
mailtemplate
'
)
def
mail_template_edit
(
request
,
pk
):
def
mail_template_edit
(
request
,
pk
):
template
=
get_object_or_404
(
MailTemplate
,
pk
=
pk
)
template
=
get_object_or_404
(
MailTemplate
,
pk
=
pk
)
if
request
.
method
==
'
POST
'
:
if
request
.
method
==
'
POST
'
:
...
@@ -82,6 +89,7 @@ class MailTemplatesDeleteView(DeleteView, WrappedView):
...
@@ -82,6 +89,7 @@ class MailTemplatesDeleteView(DeleteView, WrappedView):
success_url
=
reverse_lazy
(
'
web.views.mail_templates
'
)
success_url
=
reverse_lazy
(
'
web.views.mail_templates
'
)
template_name
=
'
mail_templates/confirm_delete.html
'
template_name
=
'
mail_templates/confirm_delete.html
'
@PermissionDecorator
(
'
change_mailtemplate
'
,
'
mailtemplate
'
)
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
messages
.
success
(
request
,
"
Template deleted
"
)
messages
.
success
(
request
,
"
Template deleted
"
)
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment