diff --git a/scipost/static/scipost/assets/js/notifications.js b/scipost/static/scipost/assets/js/notifications.js index 6f85c449bd19b4f917a6aee7affc17bdf1c267fc..5900e9eddb03d2e24297916bd10a3a260402d966 100644 --- a/scipost/static/scipost/assets/js/notifications.js +++ b/scipost/static/scipost/assets/js/notifications.js @@ -5,7 +5,7 @@ var notify_api_url_list = "/notifications/api/list/"; var notify_api_url_toggle_read = "/notifications/mark-toggle/"; var notify_api_url_mark_all_read = "/notifications/mark-all-as-read/"; var notify_fetch_count = "5"; -var notify_refresh_period = 15000; +var notify_refresh_period = 60000; var consecutive_misfires = 0; var registered_functions = [fill_notification_badge]; @@ -91,7 +91,7 @@ function fill_notification_badge(data) { } function get_notification_list() { - var data = fetch_api_data(notify_api_url_list, function(data) { + fetch_api_data(notify_api_url_list, true, function(data) { var messages = data.list.map(function (item) { var message = ''; @@ -128,10 +128,13 @@ function get_notification_list() { }); } -function fetch_api_data(url, callback) { +function fetch_api_data(url, once, callback) { if (!url) { var url = notify_api_url_count; } + if (!once) { + var once = false; + } if (registered_functions.length > 0) { //only fetch data if a function is setup @@ -153,17 +156,28 @@ function fetch_api_data(url, callback) { r.open("GET", url + '?max=' + notify_fetch_count, true); r.send(); } - if (consecutive_misfires < 10) { - setTimeout(fetch_api_data,notify_refresh_period); - } else { - var badges = document.getElementsByClassName(notify_badge_class); - if (badges) { - for (var i=0; i < badges.length; i++){ - badges[i].innerHTML = "!"; - badges[i].title = "Connection lost!" + var timer = null; + if (!once) { + if (consecutive_misfires < 10 && !once) { + timer = setTimeout(fetch_api_data, notify_refresh_period); + } else { + var badges = document.getElementsByClassName(notify_badge_class); + if (badges) { + for (var i=0; i < badges.length; i++){ + badges[i].innerHTML = "!"; + badges[i].title = "Connection lost!" + } } } } + + return stop; + function stop() { + if (timer) { + clearTimeout(timer); + timer = 0; + } + } } setTimeout(fetch_api_data, 1000); diff --git a/submissions/forms.py b/submissions/forms.py index 1fd5527db82fa9c742d3dc13888280e6852e2e85..ef88d0341896ece923b8c7d75697eaea8b29d8a9 100644 --- a/submissions/forms.py +++ b/submissions/forms.py @@ -665,7 +665,7 @@ class SubmissionCycleChoiceForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['refereeing_cycle'].default = None - other_submission = self.instance.other_versions.first() + other_submission = self.instance.other_versions_pool.first() if other_submission: self.fields['referees_reinvite'].queryset = other_submission.referee_invitations.all() diff --git a/submissions/models.py b/submissions/models.py index 401e6caef049192a906ea7e12a4d7cf2d41c4fa7..e5fb47eb4424289c7bd3dd6f6d1f1d629694db8a 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -176,6 +176,12 @@ class Submission(models.Model): @cached_property def other_versions(self): + return Submission.objects.public().filter( + arxiv_identifier_wo_vn_nr=self.arxiv_identifier_wo_vn_nr + ).exclude(pk=self.id).order_by('-arxiv_vn_nr') + + @cached_property + def other_versions_pool(self): return Submission.objects.filter( arxiv_identifier_wo_vn_nr=self.arxiv_identifier_wo_vn_nr ).exclude(pk=self.id).order_by('-arxiv_vn_nr') diff --git a/submissions/templates/submissions/editorial_page.html b/submissions/templates/submissions/editorial_page.html index 1119bd13ff47ac7c57b18b65061083199f156c80..6d29d4075433e05a154953719b270919be79b224 100644 --- a/submissions/templates/submissions/editorial_page.html +++ b/submissions/templates/submissions/editorial_page.html @@ -20,7 +20,7 @@ <div class="ml-2 mt-2"> <h3>- Go to the <a href="{% url 'submissions:submission' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">Submissions Page</a> to view Reports and Comments</h3> - {% if submission.other_versions or not submission.is_current %} + {% if submission.other_versions_pool or not submission.is_current %} <ul class="mt-3 mb-1 list-unstyled pl-4"> {% if not submission.is_current %} <li> @@ -28,10 +28,10 @@ </li> {% endif %} - {% if submission.other_versions %} + {% if submission.other_versions_pool %} <li>Other versions of this Submission exist:</li> <ul class="list-unstyled"> - {% for vn in submission.other_versions %} + {% for vn in submission.other_versions_pool %} <li>{% include 'submissions/_submission_version.html' with submission=vn editorial_page=1 %}</li> {% endfor %} </ul> diff --git a/submissions/templates/submissions/submission_detail.html b/submissions/templates/submissions/submission_detail.html index e471bbd5e786995fc619aa745daba7e181f754a1..e234d4292d5778f38c6416c809a389752e35c321 100644 --- a/submissions/templates/submissions/submission_detail.html +++ b/submissions/templates/submissions/submission_detail.html @@ -50,7 +50,7 @@ <h3 class="mt-0">- <span class="circle text-danger border-danger">!</span> You have an unfinished report for this submission, <a href="{% url 'submissions:submit_report' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">finish your report here.</a></h3> {% endif %} - {% if submission.other_versions or not submission.is_current %} + {% if submission.other_versions and not submission.is_current %} <ul class="mt-3 mb-1 list-unstyled pl-4"> {% if not submission.is_current %} <li><h3 class="text-danger">This is not the current version.</h3></li> diff --git a/submissions/views.py b/submissions/views.py index 7007d5d231c2a9af3164314afbd0f38d241bee4b..dacf0260181b637a1c60e0869e17d23277465e28 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -1501,7 +1501,7 @@ def fix_College_decision(request, rec_id): elif recommendation.recommendation == -3: # Reject + update-reject other versions of submission submission.status = 'rejected' - for sub in submission.other_versions: + for sub in submission.other_versions_pool: sub.status = 'resubmitted_rejected' sub.save()