forked from 42CTF/website
Compare commits
9 Commits
87efa03ed0
...
7b9dfad15d
Author | SHA1 | Date |
---|---|---|
Danhia | 7b9dfad15d | |
Starthur | 46ea80161d | |
Starthur | d222784bb0 | |
Starthur | 86fbf93dbf | |
Arthur-TRT | ff657c070a | |
Starthur | a1ec3e5f20 | |
Starthur | 0d7f39d335 | |
Danhia | f56322bd6e | |
Danhia | 506eb54d49 |
|
@ -7,7 +7,6 @@
|
|||
<div class="ctf-head">
|
||||
<h3>Register</h3>
|
||||
</div>
|
||||
|
||||
<div class="ctf-body sign-body">
|
||||
<div class="col-sm-8 col-md-6 mx-auto">
|
||||
{% if registered %}
|
||||
|
@ -31,7 +30,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-3 right-sidebar">
|
||||
<ul class="list-group">
|
||||
<a href="/accounts/signup" class="list-group-item">{% trans "Sign up" %}</a>
|
||||
|
@ -40,4 +39,3 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ def profile(request, user_name):
|
|||
for s in solves.reverse():
|
||||
somme += s.ctf.points
|
||||
solved.append([s.flag_date.timestamp() * 1000,somme])
|
||||
created = CTF.objects.filter(author=user_obj)
|
||||
created = CTF.objects.filter(author=user_obj, event=None)
|
||||
return render(request,'accounts/profile.html', {'user':user_obj, 'solves':solves,'solved':solved,'catsDatas': catsDatas, 'pointDatas': pointDatas,
|
||||
'rank': rank, 'score' : somme, 'member' : member, 'cats':cats, 'created':created})
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.2.11 on 2022-05-30 07:30
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0011_migration_campus'),
|
||||
('events', '0009_auto_20220215_1706'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='event',
|
||||
name='campus',
|
||||
field=models.ManyToManyField(blank=True, to='accounts.Campus'),
|
||||
),
|
||||
]
|
|
@ -2,6 +2,7 @@ from django.db import models
|
|||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import timezone
|
||||
import uuid
|
||||
from accounts.models import Campus
|
||||
|
||||
# Create your models here.
|
||||
class Event(models.Model):
|
||||
|
@ -17,6 +18,7 @@ class Event(models.Model):
|
|||
team_size = models.PositiveIntegerField(default=1)
|
||||
auto_match = models.BooleanField(default=False)
|
||||
dynamic = models.BooleanField(default=False)
|
||||
campus = models.ManyToManyField(Campus, blank=True)
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
|
|
@ -11,6 +11,21 @@
|
|||
|
||||
<div class="ctf-footer">
|
||||
{% if logged == True %}
|
||||
{% if userHasCampus == False %}
|
||||
<span class="message error-msg">
|
||||
{% trans "This event is reserved for one or more 42 campuses. If you have not connected your intranet to 42CTF, you can do so with this button: " %}
|
||||
<form action="{% url 'accounts:connections-connect-intra42' %}" method='POST' class="form-inline p-2">
|
||||
{%csrf_token%}
|
||||
<button class="btn btn-dark" type="submit">{% trans "Connect 42" %}</button>
|
||||
</form>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if campusCanJoin == False %}
|
||||
<span class="message error-msg">
|
||||
{% trans "This event is reserved for one or more 42 campuses. And unfortunately your campus can't participate. Do not hesitate to contact us to organize an event on your campus!" %}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if userHasCampus == True and campusCanJoin == True %}
|
||||
{% if wrongpwd == True %}
|
||||
<span class="message error-msg">{% trans "Wrong password submited." %}</span>
|
||||
{% endif %}
|
||||
|
@ -24,6 +39,7 @@
|
|||
<input type="text" name="password" maxlength="48" required="">
|
||||
<input class="form-control" type="submit" value=">">
|
||||
</form>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<h4>{% trans "You need to be logged to access this event." %}</h4>
|
||||
{% endif %}
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.contrib.auth.models import timezone
|
|||
from ..forms import submit_flag
|
||||
from ..models import Event, EventPlayer, Team
|
||||
from ctfs.models import CTF, CTF_flags, Category
|
||||
from accounts.models import UserProfileInfo
|
||||
from django.utils.translation import get_language
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
@ -109,13 +110,23 @@ def event(request, event_slug):
|
|||
player = None
|
||||
if player:
|
||||
IsRegistered = True
|
||||
if event_info.campus.all():
|
||||
if request.user.is_authenticated:
|
||||
if request.user.is_staff is False:
|
||||
user = UserProfileInfo.objects.get(user=request.user)
|
||||
if user.campus is None:
|
||||
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': True, 'wrongpwd': wrongpwd, 'alreadyregistered': alreadyregistered, 'userHasCampus': False, 'campusCanJoin': True})
|
||||
elif user.campus not in event_info.campus.all():
|
||||
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': True, 'wrongpwd': wrongpwd, 'alreadyregistered': alreadyregistered, 'userHasCampus': True, 'campusCanJoin': False})
|
||||
else:
|
||||
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': False, 'wrongpwd': wrongpwd, 'alreadyregistered': alreadyregistered, 'userHasCampus': True, 'campusCanJoin': True})
|
||||
if event_info.password:
|
||||
if request.user.is_authenticated:
|
||||
if request.user.is_staff is False:
|
||||
if not player:
|
||||
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': True, 'wrongpwd': wrongpwd, 'alreadyregistered': alreadyregistered})
|
||||
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': True, 'wrongpwd': wrongpwd, 'alreadyregistered': alreadyregistered, 'userHasCampus': True, 'campusCanJoin': True})
|
||||
else:
|
||||
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': False, 'wrongpwd': wrongpwd, 'alreadyregistered': alreadyregistered})
|
||||
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': False, 'wrongpwd': wrongpwd, 'alreadyregistered': alreadyregistered, 'userHasCampus': True, 'campusCanJoin': True})
|
||||
ended = False
|
||||
if timezone.now() >= event_info.end_date:
|
||||
ended = True
|
||||
|
|
Loading…
Reference in New Issue