SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
SciPost
SciPost
Commits
2a282d41
Commit
2a282d41
authored
6 years ago
by
Jean-Sébastien Caux
Browse files
Options
Downloads
Patches
Plain Diff
Add AffiliationUpdateView
parent
7cfe9650
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
profiles/urls.py
+5
-0
5 additions, 0 deletions
profiles/urls.py
profiles/views.py
+25
-0
25 additions, 0 deletions
profiles/views.py
scipost/templates/partials/scipost/personal_page/account.html
+5
-0
5 additions, 0 deletions
...ost/templates/partials/scipost/personal_page/account.html
with
35 additions
and
0 deletions
profiles/urls.py
+
5
−
0
View file @
2a282d41
...
...
@@ -77,4 +77,9 @@ urlpatterns = [
views
.
AffiliationCreateView
.
as_view
(),
name
=
'
affiliation_create
'
),
url
(
r
'
^affiliation/(?P<pk>[0-9]+)/update/$
'
,
views
.
AffiliationUpdateView
.
as_view
(),
name
=
'
affiliation_update
'
),
]
This diff is collapsed.
Click to expand it.
profiles/views.py
+
25
−
0
View file @
2a282d41
...
...
@@ -412,3 +412,28 @@ class AffiliationCreateView(UserPassesTestMixin, CreateView):
return
reverse_lazy
(
'
profiles:profile_detail
'
,
kwargs
=
{
'
pk
'
:
self
.
object
.
profile
.
id
})
return
reverse_lazy
(
'
scipost:personal_page
'
)
class
AffiliationUpdateView
(
UserPassesTestMixin
,
UpdateView
):
model
=
Affiliation
form_class
=
AffiliationForm
template_name
=
'
profiles/affiliation_form.html
'
def
test_func
(
self
):
"""
Allow creating an Affiliation if user is Admin, EdAdmin or is
the Contributor to which this Profile is related.
"""
if
self
.
request
.
user
.
has_perm
(
'
scipost.can_create_profiles
'
):
return
True
return
self
.
request
.
user
.
contributor
.
profile
is
self
.
object
.
profile
def
get_success_url
(
self
):
"""
If request.user is Admin or EdAdmin, redirect to profile detail view.
Otherwise if request.user is Profile owner, return to personal page.
"""
if
self
.
request
.
user
.
has_perm
(
'
scipost.can_create_profiles
'
):
return
reverse_lazy
(
'
profiles:profile_detail
'
,
kwargs
=
{
'
pk
'
:
self
.
object
.
profile
.
id
})
return
reverse_lazy
(
'
scipost:personal_page
'
)
This diff is collapsed.
Click to expand it.
scipost/templates/partials/scipost/personal_page/account.html
+
5
−
0
View file @
2a282d41
...
...
@@ -159,6 +159,7 @@
<th>
Category
</th>
<th>
From
</th>
<th>
Until
</th>
<td>
Actions
</td>
</tr>
</thead>
<tbody>
...
...
@@ -168,6 +169,10 @@
<td>
{{ aff.get_category_display }}
</td>
<td>
{{ aff.date_from|date:'Y-m-d' }}
</td>
<td>
{{ aff.date_until|date:'Y-m-d' }}
</td>
<td>
<ul
class=
"list-unstyled"
>
<li><a
href=
"{% url 'profiles:affiliation_update' pk=aff.id %}"
class=
"text-warning"
>
Update
</a></li>
</ul>
</tr>
{% empty %}
<tr><td
colspan=
"4"
>
No Affiliation has been defined
</td></tr>
...
...
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