Allow users to select their own default engine

Also, add this default engine and the repo to the users view
This commit is contained in:
AndyGrant committed 2019-10-24 03:27:26 -04:00
1 parent 3b574fb62a
commit 0090b64510
6 files changed
+34 -18

No files matched your search

-3
View File
@@ -32,7 +32,6 @@ FRAMEWORK_DEFAULTS = {
'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' },
'nps' : 1500000, 'nps' : 1500000,
'proto' : 'uci', 'proto' : 'uci',
'default' : True,
}, },
'Laser' : { 'Laser' : {
@@ -44,7 +43,6 @@ FRAMEWORK_DEFAULTS = {
'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' },
'nps' : 625000, 'nps' : 625000,
'proto' : 'uci', 'proto' : 'uci',
'default' : False,
}, },
'Weiss' : { 'Weiss' : {
@@ -56,7 +54,6 @@ FRAMEWORK_DEFAULTS = {
'smpltc' : { 'threads' : 8, 'hash' : 512, 'timecontrol' : '20.0+0.2' }, 'smpltc' : { 'threads' : 8, 'hash' : 512, 'timecontrol' : '20.0+0.2' },
'nps' : 4000000, 'nps' : 4000000,
'proto' : 'uci', 'proto' : 'uci',
'default' : False,
}, },
}, },
+1
View File
@@ -20,6 +20,7 @@ class Profile(Model):
games = IntegerField(default=0) games = IntegerField(default=0)
tests = IntegerField(default=0) tests = IntegerField(default=0)
repo = CharField(max_length=256, blank=True) repo = CharField(max_length=256, blank=True)
engine = CharField(max_length=128, blank=True)
enabled = BooleanField(default=False) enabled = BooleanField(default=False)
approver = BooleanField(default=False) approver = BooleanField(default=False)
updated = DateTimeField(auto_now=True) updated = DateTimeField(auto_now=True)
+2 -1
View File
@@ -89,9 +89,10 @@ def viewProfile(request):
@login_required(login_url='/login/') @login_required(login_url='/login/')
def editProfile(request): def editProfile(request):
# Update Email & Source Repo # Update Email, Source Repo, and Default Engine
profile = Profile.objects.get(user=request.user) profile = Profile.objects.get(user=request.user)
profile.user.email = request.POST['email'] profile.user.email = request.POST['email']
profile.engine = request.POST['enginename']
profile.repo = request.POST['repo'] profile.repo = request.POST['repo']
profile.save() profile.save()
+5 -4
View File
@@ -57,13 +57,14 @@
<h3> Engine </h3> <h3> Engine </h3>
<label> Name </label> <label> Name </label>
<select id="enginename" name="enginename" onchange="configure(testMode)"> <select id="enginename" name="enginename" onchange="configure(testMode)">
{% for name, data in config.engines.items %} {% for engine in config.engines %}
{% if data.default %} {% if engine == profile.engine %}
<option selected value="{{name}}">{{data.name}}</option> <option selected value="{{engine}}">{{engine}}</option>
{% else %} {% else %}
<option value="{{name}}">{{data.name}}</option> <option value="{{engine}}">{{engine}}</option>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<option value="{{engine}}">{{engine}}</option>
</select><br> </select><br>
<label> Source </label> <label> Source </label>
<input value="{{profile.repo}}" name="source"></br> <input value="{{profile.repo}}" name="source"></br>
+8
View File
@@ -13,6 +13,8 @@
<th class="numeric">Tests</th> <th class="numeric">Tests</th>
<th>Enabled</th> <th>Enabled</th>
<th>Approver</th> <th>Approver</th>
<th>Engine</th>
<th>Repo</th>
</tr> </tr>
{% for profile in profiles %} {% for profile in profiles %}
<tr> <tr>
@@ -22,10 +24,16 @@
<td class="numeric">{{profile.tests}}</td> <td class="numeric">{{profile.tests}}</td>
{% if profile.enabled %} {% if profile.enabled %}
<td class="numeric">X</td> <td class="numeric">X</td>
{% else %}
<td class="numeric"></td>
{% endif %} {% endif %}
{% if profile.approver %} {% if profile.approver %}
<td class="numeric">X</td> <td class="numeric">X</td>
{% else %}
<td class="numeric"></td>
{% endif %} {% endif %}
<td>{{profile.engine}}</td>
<td><a href="{{profile.repo}}">{{profile.repo}}</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
<table> <table>
+18 -10
View File
@@ -8,20 +8,28 @@
<form method="POST" action="/editProfile/"> <form method="POST" action="/editProfile/">
{% csrf_token %} {% csrf_token %}
<label>Username</label> <label>Username</label>
<input readonly value="{{profile.user.username}}" name="username"> <input readonly value="{{profile.user.username}}" name="username"></br>
</br>
<label>Email</label> <label>Email</label>
<input value="{{profile.user.email}}" name="email"> <input value="{{profile.user.email}}" name="email"></br>
</br>
<label>New Password</label> <label>New Password</label>
<input type="password" name="password1"> <input type="password" name="password1"></br>
</br>
<label>New Password</label> <label>New Password</label>
<input type="password" name="password2"> <input type="password" name="password2"></br>
</br>
<label>Source Repo</label> <label>Source Repo</label>
<input value="{{profile.repo}}" name="repo"> <input value="{{profile.repo}}" name="repo"></br>
</br> <label>Engine</label>
<select id="enginename" name="enginename" onchange="configure(testMode)">
{% for engine in config.engines %}
{% if profile.engine == engine %}
<option selected value="{{engine}}">{{engine}}</option>
{% else %}
<option value="{{engine}}">{{engine}}</option>
{% endif %}
{% endfor %}
{% if not profile.engine %}
<option selected value=""></option>
{% endif %}
</select><br>
<input type="submit" name="submit" value="Update Profile"> <input type="submit" name="submit" value="Update Profile">
</form> </form>
{% endblock %} {% endblock %}