Skip to content

Commit

Permalink
Merge branch 'master' into next-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRomaa authored Mar 7, 2024
2 parents 91df008 + 461e53b commit a9d6d80
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 21 deletions.
5 changes: 5 additions & 0 deletions apps/tmu/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import requests

from rest_framework import status
from rest_framework.authentication import TokenAuthentication
from rest_framework.generics import get_object_or_404
Expand Down Expand Up @@ -26,6 +28,9 @@ def post(self, request):
"""
Create new ATIS (from vATIS).
"""
# Forward request to SimTraffic so the data is replicated there
requests.post("https://api.simtraffic.net/vatis", data=request.data)

ATIS.objects.filter(facility=request.data.get("facility")).delete()
serializer = ATISSerializer(data=request.data)
if serializer.is_valid():
Expand Down
40 changes: 40 additions & 0 deletions apps/users/management/commands/sync_vatusa_roster.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,46 @@ def sync_visit_roster():
)


def sync_home_roster():
home_roster = get_vatusa_roster()

# Checks for users that do not exist on local roster.
for user in home_roster:
query = User.objects.filter(cid=user.get('cid'))
if not query.exists():
User.objects.create_user(
cid=user.get('cid'),
email=user.get('email'),
first_name=user.get('fname'),
last_name=user.get('lname'),
rating=user.get('rating_short'),
).set_membership('HC')
else:
user_obj = query.first()
user_obj.rating = user.get('rating_short')
user_obj.save()
user_obj.set_membership('HC')

# Checks for users that were removed from VATUSA roster.
cids = [user.get('cid') for user in home_roster]
for user in User.objects.filter(roles__short='HC'):
if user.cid not in cids:
user.set_membership(None)


def sync_visit_roster():
visit_roster = get_vatusa_roster('visit')
remote_cids = {user['cid'] for user in visit_roster}

# Users that have been added to the local roster but not the VATUSA roster.
for local_cid in User.objects.filter(roles__short='VC').values_list('cid', flat=True):
if local_cid not in remote_cids:
requests.post(
f'https://api.vatusa.net/v2/facility/{os.getenv("FACILITY_IATA")}/roster/manageVisitor/{local_cid}/',
params={'apikey': os.getenv('VATUSA_API_TOKEN')},
)


class Command(BaseCommand):
help = "Pulls VATUSA roster for configured facility" # noqa: A003

Expand Down
6 changes: 6 additions & 0 deletions apps/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ def set_membership(self, short, override=True):
params={"apikey": os.getenv("VATUSA_API_TOKEN")},
)

if short == 'VC':
requests.post(
f'https://api.vatusa.net/v2/facility/{os.getenv("FACILITY_IATA")}/roster/manageVisitor/{self.cid}/',
params={'apikey': os.getenv('VATUSA_API_TOKEN')},
)

self.status = Status.ACTIVE

self.save()
Expand Down
15 changes: 0 additions & 15 deletions emails/welcome_email.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,6 @@ <h3>Discord</h3>
<p>Please join our Discord server by clicking <a href="https://discord.gg/93225ukwrW" target="_blank">this link</a> or using the invite code <strong>93225ukwrW</strong>.</p>
</td>
</tr>
<tr>
<td align="left" style="padding-bottom:5px;padding-top:20px">
<h3>TeamSpeak</h3>
</td>
</tr>
<tr>
<td align="left" style="padding-top:5px;padding-bottom:10px">
<p>TeamSpeak is our primary voice communications platform. While on the network, all controllers must be in a TeamSpeak channel for coordination. TeamSpeak 3 can be downloaded at <a href="https://www.teamspeak.com/en" target="_blank">https://www.teamspeak.com/en</a>.</p>
</td>
</tr>
<tr>
<td align="left" style="padding-top:5px;padding-bottom:10px">
<p>You can connect to our server by using the IP <strong>ts.zhuartcc.org</strong>. Use your full name as your nickname when you connect. <em>Please do not share the server IP with anybody outside of the Houston ARTCC.</em></p>
</td>
</tr>
<tr>
<td align="left" style="padding-bottom:5px;padding-top:20px">
<h3>Website</h3>
Expand Down
6 changes: 0 additions & 6 deletions emails/welcome_email.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ We use Discord as our primary text communications platform. All ARTCC announceme
Please join our Discord server by visiting https://discord.gg/93225ukwrW or using the invite code 93225ukwrW.


TeamSpeak
TeamSpeak is our primary voice communications platform. While on the network, all controllers must be in a TeamSpeak channel for coordination. TeamSpeak 3 can be downloaded at https://www.teamspeak.com/en.

You can connect to our server by using the IP ts.zhuartcc.org. Use your full name as your nickname when you connect. Please do not share the server IP with anybody outside of the Houston ARTCC.


Website
Upon receiving this email, you should be able to sign in at https://zhuartcc.org using VATSIM Connect. Here you can access controlling files and facility documents, the training center, event shift bookings, and see controlling statistics.

Expand Down

0 comments on commit a9d6d80

Please sign in to comment.