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
ad302ad3
Commit
ad302ad3
authored
6 years ago
by
Jean-Sébastien Caux
Browse files
Options
Downloads
Patches
Plain Diff
Add make email primary in profile card
parent
d9d97ad6
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
profiles/forms.py
+2
-1
2 additions, 1 deletion
profiles/forms.py
profiles/templates/profiles/_profile_card.html
+3
-2
3 additions, 2 deletions
profiles/templates/profiles/_profile_card.html
profiles/urls.py
+5
-0
5 additions, 0 deletions
profiles/urls.py
profiles/views.py
+15
-3
15 additions, 3 deletions
profiles/views.py
with
25 additions
and
6 deletions
profiles/forms.py
+
2
−
1
View file @
ad302ad3
...
@@ -91,7 +91,8 @@ class ProfileMergeForm(forms.Form):
...
@@ -91,7 +91,8 @@ class ProfileMergeForm(forms.Form):
# Model fields:
# Model fields:
if
profile_to_merge
.
expertises
:
if
profile_to_merge
.
expertises
:
for
expertise
in
profile_to_merge
.
expertises
:
for
expertise
in
profile_to_merge
.
expertises
:
profile_to_merge_into
.
expertises
.
add
(
expertise
)
if
expertise
not
in
profile_to_merge_into
.
expertises
:
profile_to_merge_into
.
expertises
.
append
(
expertise
)
if
profile_to_merge
.
orcid_id
and
(
profile_to_merge_into
.
orcid_id
is
None
):
if
profile_to_merge
.
orcid_id
and
(
profile_to_merge_into
.
orcid_id
is
None
):
profile_to_merge_into
.
orcid_id
=
profile_to_merge
.
orcid_id
profile_to_merge_into
.
orcid_id
=
profile_to_merge
.
orcid_id
if
profile_to_merge
.
webpage
and
(
profile_to_merge_into
.
webpage
is
None
):
if
profile_to_merge
.
webpage
and
(
profile_to_merge_into
.
webpage
is
None
):
...
...
This diff is collapsed.
Click to expand it.
profiles/templates/profiles/_profile_card.html
+
3
−
2
View file @
ad302ad3
...
@@ -32,8 +32,9 @@
...
@@ -32,8 +32,9 @@
</td>
</td>
<td
class=
"d-flex"
>
<td
class=
"d-flex"
>
<form
method=
"post"
action=
"{% url 'profiles:toggle_email_status' profile_mail.id %}"
>
{% csrf_token %}
<button
type=
"submit"
class=
"btn btn-link p-0"
>
{{ profile_mail.still_valid|yesno:'Deprecate,Mark valid' }}
</button></form>
<form
method=
"post"
action=
"{% url 'profiles:toggle_email_status' profile_mail.id %}"
>
{% csrf_token %}
<button
type=
"submit"
class=
"btn btn-link"
>
{{ profile_mail.still_valid|yesno:'Deprecate,Mark valid' }}
</button></form>
<form
method=
"post"
action=
"{% url 'profiles:delete_profile_email' profile_mail.id %}"
>
{% csrf_token %}
<button
type=
"submit"
class=
"btn btn-link text-danger p-0 ml-2"
onclick=
"return confirm('Sure you want to delete {{ profile_mail.email }}?')"
><i
class=
"fa fa-trash"
></i></button></form>
<form
method=
"post"
action=
"{% url 'profiles:email_make_primary' profile_mail.id %}"
>
{% csrf_token %}
<button
type=
"submit"
class=
"btn btn-link"
>
Make primary
</button></form>
<form
method=
"post"
action=
"{% url 'profiles:delete_profile_email' profile_mail.id %}"
>
{% csrf_token %}
<button
type=
"submit"
class=
"btn btn-link text-danger ml-2"
onclick=
"return confirm('Sure you want to delete {{ profile_mail.email }}?')"
><i
class=
"fa fa-trash"
></i></button></form>
</td>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
...
...
This diff is collapsed.
Click to expand it.
profiles/urls.py
+
5
−
0
View file @
ad302ad3
...
@@ -57,6 +57,11 @@ urlpatterns = [
...
@@ -57,6 +57,11 @@ urlpatterns = [
views
.
add_profile_email
,
views
.
add_profile_email
,
name
=
'
add_profile_email
'
name
=
'
add_profile_email
'
),
),
url
(
r
'
^emails/(?P<email_id>[0-9]+)/make_primary$
'
,
views
.
email_make_primary
,
name
=
'
email_make_primary
'
),
url
(
url
(
r
'
^emails/(?P<email_id>[0-9]+)/toggle$
'
,
r
'
^emails/(?P<email_id>[0-9]+)/toggle$
'
,
views
.
toggle_email_status
,
views
.
toggle_email_status
,
...
...
This diff is collapsed.
Click to expand it.
profiles/views.py
+
15
−
3
View file @
ad302ad3
...
@@ -4,6 +4,7 @@ __license__ = "AGPL v3"
...
@@ -4,6 +4,7 @@ __license__ = "AGPL v3"
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.db
import
transaction
from
django.db.models
import
Q
,
Count
from
django.db.models
import
Q
,
Count
from
django.db.models.functions
import
Concat
from
django.db.models.functions
import
Concat
from
django.shortcuts
import
get_object_or_404
,
render
,
redirect
from
django.shortcuts
import
get_object_or_404
,
render
,
redirect
...
@@ -249,9 +250,6 @@ class ProfileDuplicateListView(PermissionsMixin, ListView):
...
@@ -249,9 +250,6 @@ class ProfileDuplicateListView(PermissionsMixin, ListView):
nr_count
=
Count
(
'
full_name
'
)
nr_count
=
Count
(
'
full_name
'
)
).
filter
(
nr_count__gt
=
1
)
).
filter
(
nr_count__gt
=
1
)
queryset
=
profiles
.
filter
(
full_name__in
=
[
item
[
'
full_name
'
]
for
item
in
duplicates
])
queryset
=
profiles
.
filter
(
full_name__in
=
[
item
[
'
full_name
'
]
for
item
in
duplicates
])
# duplicates = Profile.objects.values('last_name').annotate(
# nr=Count('last_name')).filter(nr__gt=1)
# queryset = Profile.objects.filter(last_name__in=[item['last_name'] for item in duplicates])
return
queryset
return
queryset
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
...
@@ -260,6 +258,7 @@ class ProfileDuplicateListView(PermissionsMixin, ListView):
...
@@ -260,6 +258,7 @@ class ProfileDuplicateListView(PermissionsMixin, ListView):
return
context
return
context
@transaction.atomic
@permission_required
(
'
scipost.can_create_profiles
'
)
@permission_required
(
'
scipost.can_create_profiles
'
)
def
profile_merge
(
request
):
def
profile_merge
(
request
):
"""
"""
...
@@ -302,6 +301,19 @@ def add_profile_email(request, profile_id):
...
@@ -302,6 +301,19 @@ def add_profile_email(request, profile_id):
return
redirect
(
reverse
(
'
profiles:profiles
'
))
return
redirect
(
reverse
(
'
profiles:profiles
'
))
@require_POST
@permission_required
(
'
scipost.can_create_profiles
'
)
def
email_make_primary
(
request
,
email_id
):
"""
Make this email the primary one for this Profile.
"""
profile_email
=
get_object_or_404
(
ProfileEmail
,
pk
=
email_id
)
ProfileEmail
.
objects
.
filter
(
profile
=
profile_email
.
profile
).
update
(
primary
=
False
)
profile_email
.
primary
=
True
profile_email
.
save
()
return
redirect
(
profile_email
.
profile
.
get_absolute_url
())
@require_POST
@require_POST
@permission_required
(
'
scipost.can_create_profiles
'
)
@permission_required
(
'
scipost.can_create_profiles
'
)
def
toggle_email_status
(
request
,
email_id
):
def
toggle_email_status
(
request
,
email_id
):
...
...
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