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
476baed6
Commit
476baed6
authored
5 years ago
by
Jean-Sébastien Caux
Browse files
Options
Downloads
Patches
Plain Diff
Move conflicts javascript to static file
parent
060a3b7f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scipost/static/scipost/update-conflict.js
+51
-0
51 additions, 0 deletions
scipost/static/scipost/update-conflict.js
submissions/templates/partials/submissions/admin/conflicts.html
+5
-48
5 additions, 48 deletions
...sions/templates/partials/submissions/admin/conflicts.html
with
56 additions
and
48 deletions
scipost/static/scipost/update-conflict.js
0 → 100644
+
51
−
0
View file @
476baed6
function
csrfSafeMethod
(
method
)
{
// these HTTP methods do not require CSRF protection
return
(
/^
(
GET|HEAD|OPTIONS|TRACE
)
$/
.
test
(
method
));
}
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!==
''
)
{
var
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
// Does this cookie string begin with the name we want?
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
===
(
name
+
'
=
'
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
}
}
}
return
cookieValue
;
}
var
csrftoken
=
getCookie
(
'
csrftoken
'
);
function
update_conflict
(
conflict_id
,
status
,
url
)
{
$
.
ajax
({
"
method
"
:
"
POST
"
,
"
url
"
:
url
,
"
data
"
:
{
'
status
'
:
status
,
'
csrftoken
'
:
getCookie
(
'
csrftoken
'
),
},
"
beforeSend
"
:
function
(
xhr
,
settings
)
{
if
(
!
csrfSafeMethod
(
settings
.
type
)
&&
!
this
.
crossDomain
)
{
xhr
.
setRequestHeader
(
"
X-CSRFToken
"
,
csrftoken
);
}
},
}).
done
(
function
(
data
)
{
if
(
data
[
'
status
'
]
==
'
verified
'
)
{
$
(
"
#conflict-
"
+
data
[
'
id
'
]
+
"
.status
"
).
html
(
'
<i class="fa-li fa fa-check-circle text-success" aria-hidden="true"></i> Verified by Admin
'
);
}
else
if
(
data
[
'
status
'
]
==
'
deprecated
'
)
{
$
(
"
#conflict-
"
+
data
[
'
id
'
]
).
fadeTo
(
"
fast
"
,
0.3
).
find
(
'
.status
'
).
html
(
'
<i class="fa-li fa fa-times-circle text-danger" aria-hidden="true"></i> <em>Deleted</em>
'
);
}
});
}
$
(
document
).
ready
(
function
()
{
$
(
'
.update-conflict-button
'
).
on
(
'
click
'
,
function
()
{
id
=
$
(
this
).
data
(
'
conflict-id
'
);
status
=
$
(
this
).
data
(
'
status
'
);
url
=
$
(
this
).
data
(
'
urllink
'
);
update_conflict
(
id
,
status
,
url
);
});
});
This diff is collapsed.
Click to expand it.
submissions/templates/partials/submissions/admin/conflicts.html
+
5
−
48
View file @
476baed6
{% load static %}
{% if conflicts %}
{% if conflicts %}
{{ conflicts|length }} (potential) conflict{{ conflicts|length|pluralize }} found:
{{ conflicts|length }} (potential) conflict{{ conflicts|length|pluralize }} found:
<ul
class=
"fa-ul mt-2"
>
<ul
class=
"fa-ul mt-2"
>
...
@@ -7,10 +9,9 @@
...
@@ -7,10 +9,9 @@
{% if conflict.status == 'unverified' %}
{% if conflict.status == 'unverified' %}
<i
class=
"fa-li fa fa-question-circle text-warning"
aria-hidden=
"true"
></i>
<i
class=
"fa-li fa fa-question-circle text-warning"
aria-hidden=
"true"
></i>
Please
Please
<button
type=
"button"
class=
"btn btn-link p-0
"
on
c
lic
k=
"up
dat
e_
conflict
(
{{ conflict.id }}
, 'verified')"
>
verify
</button>
<button
type=
"button"
class=
"btn btn-link p-0
update-c
on
f
lic
t-button"
dat
a-
conflict
-id=
"
{{ conflict.id }}
"
data-status=
"verified"
data-urllink=
"{% url 'api:conflictofinterest-verify_conflict' conflict.id %}"
>
confirm
</button>
or
or
<button
type=
"button"
class=
"btn btn-link p-0 text-danger"
onclick=
"update_conflict({{ conflict.id }}, 'delete')"
>
delete
</button>
<button
type=
"button"
class=
"btn btn-link p-0 text-danger update-conflict-button"
data-conflict-id=
"{{ conflict.id }}"
data-status=
"delete"
data-urllink=
"{% url 'api:conflictofinterest-verify_conflict' conflict.id %}"
>
delete
</button>
this conflict.
this conflict.
{% elif conflict.status == 'verified' %}
{% elif conflict.status == 'verified' %}
<i
class=
"fa-li fa fa-check-circle text-success"
aria-hidden=
"true"
></i>
<i
class=
"fa-li fa fa-check-circle text-success"
aria-hidden=
"true"
></i>
...
@@ -40,49 +41,5 @@
...
@@ -40,49 +41,5 @@
{% block footer_script %}
{% block footer_script %}
<script
type=
"text/javascript"
nonce=
"{{ request.csp_nonce }}"
>
<script
src=
"{% static 'scipost/update-conflict.js' %}"
></script>
function
csrfSafeMethod
(
method
)
{
// these HTTP methods do not require CSRF protection
return
(
/^
(
GET|HEAD|OPTIONS|TRACE
)
$/
.
test
(
method
));
}
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!==
''
)
{
var
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
// Does this cookie string begin with the name we want?
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
===
(
name
+
'
=
'
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
}
}
}
return
cookieValue
;
}
var
csrftoken
=
getCookie
(
'
csrftoken
'
);
function
update_conflict
(
conflict_id
,
status
)
{
$
.
ajax
({
"
method
"
:
"
POST
"
,
"
url
"
:
"
{% url 'api:conflictofinterest-verify_conflict' 0 %}
"
.
replace
(
"
0
"
,
conflict_id
),
"
data
"
:
{
'
status
'
:
status
,
'
csrftoken
'
:
getCookie
(
'
csrftoken
'
),
},
"
beforeSend
"
:
function
(
xhr
,
settings
)
{
if
(
!
csrfSafeMethod
(
settings
.
type
)
&&
!
this
.
crossDomain
)
{
xhr
.
setRequestHeader
(
"
X-CSRFToken
"
,
csrftoken
);
}
},
}).
done
(
function
(
data
)
{
if
(
data
[
'
status
'
]
==
'
verified
'
)
{
$
(
"
#conflict-
"
+
data
[
'
id
'
]
+
"
.status
"
).
html
(
'
<i class="fa-li fa fa-check-circle text-success" aria-hidden="true"></i> Verified by Admin
'
);
}
else
if
(
data
[
'
status
'
]
==
'
deprecated
'
)
{
$
(
"
#conflict-
"
+
data
[
'
id
'
]
).
fadeTo
(
"
fast
"
,
0.3
).
find
(
'
.status
'
).
html
(
'
<i class="fa-li fa fa-times-circle text-danger" aria-hidden="true"></i> <em>Deleted</em>
'
);
}
});
}
</script>
{% endblock %}
{% endblock %}
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