-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #573 from rdmorganiser/dev
RDMO 1.9.1
- Loading branch information
Showing
29 changed files
with
274 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sys | ||
import csv | ||
|
||
from datetime import datetime | ||
|
||
import pytz | ||
|
||
from django.contrib.auth.models import User | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
columns = ('id', 'username', 'first_name', 'last_name', 'email', 'date_joined', 'last_login') | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('since', | ||
type=lambda s: pytz.utc.localize(datetime.strptime(s, '%Y-%m-%d')), | ||
help='Date since the users have been inactive (format: "2022-12-31").') | ||
parser.add_argument('-o|--output-file', dest='output_file', default=None, | ||
help='Store the output in a csv file.') | ||
|
||
def handle(self, *args, **options): | ||
rows = User.objects.filter(last_login__lt=options['since']) \ | ||
.order_by('-last_login').values_list(*self.columns) | ||
|
||
if rows: | ||
fp = open(options['output_file'], 'w') if options['output_file'] else sys.stdout | ||
csv_writer = csv.writer(fp) | ||
csv_writer.writerow(self.columns) | ||
csv_writer.writerows(rows) | ||
fp.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import re | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from rdmo.projects.models import Project | ||
|
||
|
||
class Command(BaseCommand): | ||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
'id_list_file', type=str, | ||
help='required list of project ids to delete in plain text format, ' + | ||
'project ids have to be at the beginning of the line, ' + | ||
'supports commenting lines out: if a line does ' + | ||
'not start with an integer it will be skipped' | ||
) | ||
|
||
def handle(self, *args, **options): | ||
project_ids = set() | ||
with open(options['id_list_file']) as fp: | ||
for line in fp.readlines(): | ||
m = re.search(r'^([0-9]+)', line) | ||
if m: | ||
project_ids.add(int(m.group(1))) | ||
|
||
if input(f'You are about to delete {len(project_ids)} projects. ' | ||
'Are you sure? If so please enter \'yes\' to continue: ') == 'yes': | ||
for project in Project.objects.filter(id__in=project_ids): | ||
project.delete() | ||
print(f'Project {project} deleted.') | ||
else: | ||
print('Aborted!') |
44 changes: 44 additions & 0 deletions
44
rdmo/projects/management/commands/find_inactive_projects.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import sys | ||
import csv | ||
|
||
from datetime import datetime | ||
|
||
import pytz | ||
|
||
from django.db import models | ||
from django.db.models.functions import Greatest | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
from rdmo.projects.models import Project, Value | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
columns = ('id', 'title', 'created', 'updated', 'last_changed') | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('since', | ||
type=lambda s: pytz.utc.localize(datetime.strptime(s, '%Y-%m-%d')), | ||
help='Date since the projects have been inactive (format: 2022-12-31).') | ||
parser.add_argument('-o|--output-file', dest='output_file', default=None, | ||
help='Store the output in a csv file.') | ||
|
||
def handle(self, *args, **options): | ||
# prepare subquery for last_changed | ||
last_changed_subquery = models.Subquery( | ||
Value.objects.filter(project=models.OuterRef('pk')).order_by('-updated').values('updated')[:1] | ||
) | ||
|
||
# prepare actual query | ||
rows = Project.objects.annotate(last_changed=Greatest('updated', last_changed_subquery)) \ | ||
.filter(last_changed__lt=options['since']) \ | ||
.order_by('-last_changed') \ | ||
.values_list(*self.columns) | ||
|
||
if rows: | ||
fp = open(options['output_file'], 'w') if options['output_file'] else sys.stdout | ||
csv_writer = csv.writer(fp) | ||
csv_writer.writerow(self.columns) | ||
csv_writer.writerows(rows) | ||
fp.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/issue_send_support_info_de.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Unterstützung" | ||
data-placement="bottom"> | ||
|
||
Falls Sie weitere Fragen haben, wenden Sie sich gern an Ihre lokale Kontaktperson zum Thema Forschungsdaten. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/issue_send_support_info_en.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Support" | ||
data-placement="bottom"> | ||
|
||
If you have further questions, please do not hesitate to ask your local contact person for research data management. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/issue_send_support_info_fr.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Support" | ||
data-placement="bottom"> | ||
|
||
Si vous avez d'autres questions, n'hésitez pas à vous adresser à votre personne de contact locale pour la gestion des données de recherche. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/issue_send_support_info_it.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Supporto" | ||
data-placement="bottom"> | ||
|
||
Per ulteriori domande, non esitate a rivolgervi al vostro referente locale per la gestione dei dati di ricerca. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/project_support_info_de.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Unterstützung" | ||
data-placement="bottom"> | ||
|
||
Falls Sie weitere Fragen haben, wenden Sie sich gern an Ihre lokale Kontaktperson zum Thema Forschungsdaten. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/project_support_info_en.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Support" | ||
data-placement="bottom"> | ||
|
||
If you have further questions, please do not hesitate to ask your local contact person for research data management. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/project_support_info_fr.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Support" | ||
data-placement="bottom"> | ||
|
||
Si vous avez d'autres questions, n'hésitez pas à vous adresser à votre personne de contact locale pour la gestion des données de recherche. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/project_support_info_it.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Supporto" | ||
data-placement="bottom"> | ||
|
||
Per ulteriori domande, non esitate a rivolgervi al vostro referente locale per la gestione dei dati di ricerca. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/projects_support_info_de.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Unterstützung" | ||
data-placement="bottom"> | ||
|
||
Falls Sie weitere Fragen haben, wenden Sie sich gern an Ihre lokale Kontaktperson zum Thema Forschungsdaten. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/projects_support_info_en.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Support" | ||
data-placement="bottom"> | ||
|
||
If you have further questions, please do not hesitate to ask your local contact person for research data management. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
rdmo/projects/templates/projects/overlays/projects_support_info_fr.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="overlay" id="support-info-overlay" | ||
data-title="Support" | ||
data-placement="bottom"> | ||
|
||
Si vous avez d'autres questions, n'hésitez pas à vous adresser à votre personne de contact locale pour la gestion des données de recherche. | ||
|
||
{% include 'overlays/buttons.html'%} | ||
</div> |
Oops, something went wrong.