From 5a9bb3ea51ed91489cc7fb514c2432350c5a4be4 Mon Sep 17 00:00:00 2001 From: nova Date: Mon, 29 Jul 2024 22:06:03 +0000 Subject: [PATCH] changes from nova --- net/find.py | 24 ++++++++++++++++++++++++ net/merge-user.py | 6 +++--- net/static/robots.txt | 3 +++ net/templates/user_image/view.html | 2 +- net/update-user.py | 6 +++--- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/net/find.py b/net/find.py index 4b4f2b34b..2ba6535c4 100644 --- a/net/find.py +++ b/net/find.py @@ -60,6 +60,8 @@ def main(): parser.add_option('-j', '--job', type=int, dest='job', help='Job ID') parser.add_option('-u', '--userimage', type=int, dest='uimage', help='UserImage ID') parser.add_option('-e', '--email', help='Find user id with given email address') + parser.add_option('--apikey', help='Find user id with given API key') + parser.add_option('--newkey', default=False, action='store_true', help='Generate new API key for this user (use with --apikey).') parser.add_option('-U', '--userid', help='Find user with given numerical ID', type=int) parser.add_option('-i', '--image', type=int, dest='image', help='Image ID') parser.add_option('-d', '--disk-file', type=str, dest='df', help='DiskFile id') @@ -72,6 +74,9 @@ def main(): parser.add_option('--chown', dest='chown', type=int, default=0, help='Change owner of userimage or submission by user id #') + parser.add_option('--public', default=False, action='store_true', help='Set UserImage to publicly visible') + parser.add_option('--private', default=False, action='store_true', help='Set UserImage to not publicly visible') + parser.add_option('--solve-command', help='Command to run instead of ssh to actually solve image') parser.add_option('--solve-locally', @@ -128,12 +133,26 @@ def main(): delete_user(u) sys.exit(0) + if opt.apikey: + up = UserProfile.objects.filter(apikey=opt.apikey) + print('Users with API key %s:' % opt.apikey) + for upx in up: + u = upx.user + print(u.id, u, u.email) + if opt.newkey: + print('Generating new API key...') + upx.create_api_key() + print('New API key:', upx.apikey) + upx.save() + sys.exit(0) + if opt.userid: users = User.objects.filter(id=opt.userid) print('Users with ID', opt.userid) for u in users: print(u.id, u, u.email) print(u.profile) + print('Is authenticated:', u.is_authenticated) # print('User dir():', dir(u)) for k in ['email', 'first_name', 'last_name', 'profile', 'social_auth', 'username']: print(' ', k, getattr(u,k), repr(getattr(u,k))) @@ -358,6 +377,11 @@ def main(): ui.user = user ui.save() + if opt.public: + ui.unhide() + if opt.private: + ui.hide() + if opt.delete: print('Deleting ui', ui) ui.delete() diff --git a/net/merge-user.py b/net/merge-user.py index 91928ff25..265dd6650 100644 --- a/net/merge-user.py +++ b/net/merge-user.py @@ -23,12 +23,12 @@ #print(' User', u.id, 'has', nsub, 'Submissions') print(users.count(), 'Users match') -if False: +if True: bestuser = None nmax = 0 for u in users: nsub = u.submissions.count() - print(' User', u.id, 'has', nsub, 'Submissions') + print(' User', u.id, 'email', u.email, 'has', nsub, 'Submissions') if nsub > nmax: bestuser = u nmax = nsub @@ -38,7 +38,7 @@ print(' User', u.id, 'has', nsub, 'Submissions') #bestuser = User.objects.get(id=43427) -bestuser = users[0] +#bestuser = users[0] print('Updating to user:', bestuser, 'id', bestuser.id) #users = list(users) + [bestuser] diff --git a/net/static/robots.txt b/net/static/robots.txt index 7f06c99b6..fc93fbf5b 100644 --- a/net/static/robots.txt +++ b/net/static/robots.txt @@ -1,3 +1,6 @@ +User-agent: * +Disallow: / + User-agent: GPTBot Disallow: / diff --git a/net/templates/user_image/view.html b/net/templates/user_image/view.html index f41a5f755..b036d4fa7 100644 --- a/net/templates/user_image/view.html +++ b/net/templates/user_image/view.html @@ -179,7 +179,7 @@

Calibration

Pixel scale:{{ calib.format_pixscale }} - Orientation:{{ calib.format_orientation }} + "Orientation", may be incorrect, use at your own risk:{{ calib.format_orientation }} WCS file: diff --git a/net/update-user.py b/net/update-user.py index cebf89562..ed97aaa99 100644 --- a/net/update-user.py +++ b/net/update-user.py @@ -22,9 +22,9 @@ print(' ', u.id, u, u.email) print(u.get_full_name(), u.profile, u.first_name, u.get_username(), u.username) print('date joined', u.date_joined) - u.profile.create_api_key() - u.profile.save() - print('New API key:', u.profile.apikey) + #u.profile.create_api_key() + #u.profile.save() + #print('New API key:', u.profile.apikey) #print(dir(u)) # print('Generating new API key')