no mapwidgets for us atm, better luck next time

parent 016f0fc0
Pipeline #20223797 failed with stage
in 18 minutes and 57 seconds
......@@ -9,7 +9,6 @@ from django.forms import ValidationError
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django_countries.fields import CountryField
from mapwidgets.widgets import GooglePointFieldWidget
from failmap.game.models import Contest, OrganizationSubmission, Team, UrlSubmission
from failmap.organizations.models import Organization, OrganizationType, Url
......@@ -42,31 +41,32 @@ class TeamForm(forms.Form):
team = forms.ModelChoiceField(
widget=forms.RadioSelect,
queryset=Team.objects.all().filter(
allowed_to_submit_things=True, participating_in_contest=get_default_contest()))
allowed_to_submit_things=True, participating_in_contest=get_default_contest()),
)
def clean(self):
cleaned_data = super().clean()
team = cleaned_data.get("team")
secret = cleaned_data.get("secret")
log.error("%s %s", team, secret)
# validate secret, add some timing...
time.sleep(1) # wait a second to deter brute force attacks (you can still do them)
try:
team = Team.objects.all().get(id=team.id, secret=secret)
except Team.DoesNotExist:
raise ValidationError(
_('Incorrect secret or team. Try again!'),
code='invalid',
)
# it's possible NOT to select a team, in that case, don't try and validate secret.
if team:
try:
team = Team.objects.all().get(id=team.id, secret=secret)
except Team.DoesNotExist:
raise ValidationError(
_('Incorrect secret or team. Try again!'),
code='invalid',
)
class Meta:
# class Meta:
# model = UrlSubmission # not bound to a model, we have to write save ourselves since we want to do
# a bit of dirty hacks (to prevent more N-N fields).
fields = ('team', 'secret', )
# fields = ('team', 'secret', )
# http://django-autocomplete-light.readthedocs.io/en/master/tutorial.html
......@@ -91,7 +91,7 @@ class OrganisationSubmissionForm(forms.ModelForm):
# todo: show map, view only.
fields = ('organization_type_name', 'organization_name', 'organization_address_geocoded',)
widgets = {'organization_address_geocoded': GooglePointFieldWidget}
# widgets = {'organization_address_geocoded': GooglePointFieldWidget}
class UrlSubmissionForm(forms.Form):
......
......@@ -141,18 +141,32 @@ def teams(request):
form = TeamForm(request.POST)
if form.is_valid():
request.session['team'] = form.cleaned_data['team'].id
form = TeamForm()
if form.cleaned_data['team']:
request.session['team'] = form.cleaned_data['team'].id
else:
request.session['team'] = None
request.session.modified = True
request.session.save()
form = TeamForm({'team': get_team_id(request)})
else:
form = TeamForm()
form = TeamForm({'team': get_team_id(request)})
return render(request, 'game/submit_team.html', {'form': form, 'team': get_team_info(request)})
def get_team_id(request):
try:
team = Team.objects.get(pk=request.session.get('team', 0))
except (ObjectDoesNotExist, ValueError):
team = {"id": "-"}
return team
def get_team_info(request):
try:
team = Team.objects.get(pk=request.session.get('team', '-'))
team = Team.objects.get(pk=request.session.get('team', 0))
except (ObjectDoesNotExist, ValueError):
team = {"name": "-"}
return team
......
......@@ -46,6 +46,8 @@ def compose_task(
tasks.append(chain(explore, scan))
task = group(tasks)
print("Tasks:")
print(task)
return task
......
......@@ -292,14 +292,16 @@ def resolve_and_scan(protocol: str, url: Url, port: int):
def resolve_and_scan_tasks(protocol: str, url: Url, port: int):
# todo: give ips als argument in kill an revive.
task = chain(
get_ips.si(url.url),
group(store_url_ips_task.s(url),
kill_url_task.s(url),
revive_url_task.s(url),
can_connect_ips.s(protocol, url, port, 4) | connect_result.s(protocol, url, port, 4),
can_connect_ips.s(protocol, url, port, 6) | connect_result.s(protocol, url, port, 6),
)
task = group(
chain(
get_ips.si(url.url),
group(store_url_ips_task.s(url),
kill_url_task.s(url),
revive_url_task.s(url),
),
),
get_ips.si(url.url) | can_connect_ips.s(protocol, url, port, 4) | connect_result.s(protocol, url, port, 4),
get_ips.si(url.url) | can_connect_ips.s(protocol, url, port, 6) | connect_result.s(protocol, url, port, 6),
)
return task
......
......@@ -94,4 +94,4 @@ django-fsm-log
django-crispy-forms
django-autocomplete-light
geocoder
django-map-widgets
# django-map-widgets # uses gdal, not in alpine, cannot be fixed quickly so not using this.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment