Skip to content

Commit

Permalink
Merge branch 'main' of github.com:dstndstn/astrometry.net
Browse files Browse the repository at this point in the history
  • Loading branch information
dstndstn committed Jul 29, 2024
2 parents 8a94757 + be1aead commit 7a31e88
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
24 changes: 24 additions & 0 deletions net/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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',
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions net/merge-user.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,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
Expand Down
3 changes: 3 additions & 0 deletions net/static/robots.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
User-agent: *
Disallow: /

User-agent: GPTBot
Disallow: /

Expand Down
2 changes: 1 addition & 1 deletion net/templates/user_image/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ <h3>Calibration</h3>
<td>Pixel scale:</td><td>{{ calib.format_pixscale }}</td>
</tr>
<tr>
<td>Orientation:</td><td>{{ calib.format_orientation }}</td>
<td>"Orientation", <a href="https://github.com/dstndstn/astrometry.net/issues/151">may be incorrect</a>, use at your own risk:</td><td>{{ calib.format_orientation }}</td>
</tr>
<tr>
<td>WCS file:</td>
Expand Down
6 changes: 3 additions & 3 deletions net/update-user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 7a31e88

Please sign in to comment.