Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit c0c6da2

Browse files
committed
Merge branch 'release/v0.8.7'
2 parents b2789b1 + bf77d77 commit c0c6da2

11 files changed

Lines changed: 79 additions & 41 deletions

File tree

ajax/views/admin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.contrib.auth.decorators import login_required, permission_required
22
from django.db.models import F, Count, Value, CharField, IntegerField
33
from django.views.decorators.http import require_http_methods
4+
from django.conf import settings
45

56
from ajax.views import renderer
67
from core.models import User, ServerGroup
@@ -21,7 +22,7 @@ def user(request, page, *args, **kwargs):
2122

2223
ext = User.objects.filter(is_superuser=True) \
2324
.annotate(server=Value(None, CharField(null=True))) \
24-
.annotate(role=Value('root', CharField())) \
25+
.annotate(role=Value(settings.ROOT, CharField())) \
2526
.annotate(role_id=Value(0, IntegerField())) \
2627
.annotate(location=F('country__code'))
2728
return renderer(request, 'partials/admin/user.pug', obj, page, extra=ext)

api/lib/steam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def search(query=''):
3333
files={
3434
},
3535
)
36-
response = json.loads(response.content)
36+
response = json.loads(response.content.decode())
3737

3838
html = etree.HTML(response['html'])
3939
results = CSSSelector('div.search_row')

api/views/user.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.contrib.auth.models import Group, Permission
77
from django.db.models import F, Q, DateTimeField, ExpressionWrapper
88
from django.utils import timezone
9+
from django.conf import settings
910
from django.views.decorators.csrf import csrf_exempt
1011
from django.views.decorators.http import require_http_methods
1112

@@ -173,7 +174,7 @@ def detailed(request, u=None, s=None, validated={}, *args, **kwargs):
173174

174175
if user.is_superuser:
175176
# fake root role
176-
output['roles'].append({'name': 'root',
177+
output['roles'].append({'name': settings.ROOT,
177178
'server': None,
178179
'flags': 'ABCDEFGHIJKLNMNOPQRSTUVXYZ'.lower(),
179180
'immunity': 100,

cli/install.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ install() {
154154
case $yn in
155155
[Yy]* ) read -p "Where should hawthorne be installed? " directory; break;;
156156
[Nn]* ) break;;
157-
* ) echo "Please answer with the answers provided.";;
157+
* ) echo "Please answer with the choices provided.";;
158158
esac
159159
done
160160
fi
@@ -226,6 +226,7 @@ install() {
226226
}
227227

228228
ln -s /usr/local/bin/python3 /usr/bin/python3
229+
ln -s /usr/local/bin/pip3 /usr/bin/pip3
229230
/usr/sbin/setsebool -P httpd_can_network_connect 1
230231
else
231232
printf "Your package manager is currently not supported. Please contact the maintainer\n"
@@ -335,6 +336,7 @@ configure() {
335336
exit 1
336337
fi
337338
fi
339+
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u $dbuser mysql
338340

339341
if [ "$stapi" = "" ]; then
340342
printf "\n\n${GREEN}SteamAPI configuration:${NORMAL}\n"
@@ -379,13 +381,12 @@ configure() {
379381
while true; do
380382
read -p "Is your webserver ${BOLD}(A)${NORMAL}pache, ${BOLD}(N)${NORMAL}ginx or ${BOLD}(D)${NORMAL}ifferent? " yn
381383
case $yn in
382-
[Aa]* ) sed -i "s#bind = 'unix:/tmp/sockets/hawthorne.sock'#bind = '127.0.0.1:8000'#g" $directory/gunicorn.conf.py
383-
web="apache"
384+
[Aa]* ) web="apache"
384385
break;;
385386
[Nn]* ) break;;
386387
[Dd]* ) web="unspecified"
387388
break;;
388-
* ) echo "Please answer with the answers provided.";;
389+
* ) echo "Please answer with the choices provided.";;
389390
esac
390391
done
391392
fi
@@ -396,7 +397,7 @@ configure() {
396397
case $yn in
397398
[Ii]* ) domain=$(curl -sSSL "https://api.ipify.org/?format=text"); break;;
398399
[Dd]* ) read -p "Which (sub-)domain will hawthorne be hosted? " domain; break;;
399-
* ) echo "Please answer with the answers provided.";;
400+
* ) echo "Please answer with the choices provided.";;
400401
esac
401402
done
402403
fi
@@ -422,6 +423,7 @@ configure() {
422423
export LC_ALL=en_US.UTF-8
423424

424425
sed -i "s#bind = 'unix:/tmp/sockets/hawthorne.sock'#bind = '0.0.0.0:8000'#g" $directory/gunicorn.conf.py
426+
sed -i "s#ROOT = 'root'#ROOT = '$ROOT'#g" $directory/panel/local.py
425427

426428
cd $directory
427429
python3 -m gunicorn.app.wsgiapp panel.wsgi:application
@@ -448,10 +450,12 @@ configure() {
448450
printf "For additional information about the configuration please refer to ${YELLOW}https://docs.hawthorne.in/#/getting-started?id=web-server-configuration${NORMAL}\n\n\n"
449451

450452
if [ $nginx -ne 2 ]; then
453+
echo "$web"
451454
printf "${GREEN}These example configurations have been specificially generated for your system, they might need some tweaking: ${NORMAL}\n\n\n"
452455
if [ "$web" = "nginx" ]; then
453456
sed "s/server_name example.com;/server_name '$domain';/g" $directory/cli/configs/nginx.example.conf
454457
elif [ "$web" = "apache" ]; then
458+
sed -i "s#bind = 'unix:/tmp/sockets/hawthorne.sock'#bind = '127.0.0.1:8000'#g" $directory/gunicorn.conf.py
455459
sed "s/ServerName example.com/ServerName '$domain'/g" $directory/cli/configs/apache.example.conf
456460
fi
457461
fi

cli/toolchain.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ update () {
5858
# echo "ALTER TABLE auth_permission AUTO_INCREMENT = 1;" | python3 manage.py dbshell
5959
# python3 manage.py migrate --run-syncdb
6060

61+
dbuser=$(cat panel/local.py | grep -oP "(?<='USER': ')[a-zA-Z0-9\.-]*(?=',)")
62+
export MYSQL_PWD=$(cat panel/local.py | grep -oP "(?<='PASSWORD': ')[a-zA-Z0-9\.-]*(?=',)")
63+
export MYSQL_HOST=$(cat panel/local.py | grep -oP "(?<='HOST': ')[a-zA-Z0-9\.-]*(?=',)")
64+
export MYSQL_TCP_PORT=$(cat panel/local.py | grep -oP "(?<='PORT': ')[a-zA-Z0-9\.-]*(?=',)")
65+
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u $dbuser mysql
66+
6167
hash supervisorctl >/dev/null 2>&1 || {
6268
printf "${YELLOW}Was unable to detect supervisor - not attempting to restart wsgi\n${NORMAL}"
6369
exit 1

cli/utils/docker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ DB_PORT=$(echo $DB | sed -nE 's#.*[\:]([0-9]+)\/.*#\1#p')
55
DB_PORT=${DB_PORT:-3306}
66

77
DEMO=${DEMO:-0}
8+
ROOT=${ROOT:-root}
89

910
edis-server --daemonize yes
1011
/hawthorne/cli/utils/wait.sh ${DB_HOST}:${DB_PORT}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 2.0.5 on 2018-06-15 20:33
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('core', '0062_punishment_is_kicked'),
11+
]
12+
13+
operations = [
14+
migrations.RemoveField(
15+
model_name='user',
16+
name='tag'
17+
),
18+
migrations.AddField(
19+
model_name='user',
20+
name='tag',
21+
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Tag'),
22+
),
23+
]

core/models.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,37 @@ class Meta:
1313
abstract = True
1414

1515

16+
class Tag(BaseModel):
17+
name = models.CharField(max_length=255, null=True)
18+
19+
COLORS = (
20+
("default", "Default Color"),
21+
("teamcolor", "Current Team Color"),
22+
("red", "Red"),
23+
("lightred", "Lighter Red"),
24+
("darkred", "Darker Red"),
25+
("bluegrey", "Blueish Grey"),
26+
("blue", "Blue"),
27+
("darkblue", "Darker Blue"),
28+
("purple", "Purple"),
29+
("orchid", "Orchid"),
30+
("yellow", "Yellow"),
31+
("gold", "Gold"),
32+
("lightgreen", "Lighter Green"),
33+
("green", "Green"),
34+
("lime", "Lime"),
35+
("grey", "Grey"),
36+
("darkgrey", "Darker Grey"),
37+
)
38+
39+
# colors
40+
chat = models.CharField(max_length=10, choices=COLORS, default="default")
41+
name = models.CharField(max_length=10, choices=COLORS, default="default")
42+
43+
# nametag
44+
base = models.CharField(max_length=10, choices=COLORS, default="default")
45+
46+
1647
class Mainframe(BaseModel):
1748
assigned = models.UUIDField(null=True)
1849
token = models.UUIDField(null=True)
@@ -57,7 +88,7 @@ class User(AbstractUser):
5788
created_at = models.DateTimeField(auto_now_add=True)
5889
updated_at = models.DateTimeField(auto_now=True)
5990

60-
tag = models.CharField(max_length=255, null=True)
91+
tag = models.ForeignKey(Tag, on_delete=models.CASCADE, null=True)
6192

6293
class Meta:
6394
permissions = [
@@ -167,37 +198,6 @@ def __str__(self):
167198
return self.convert()
168199

169200

170-
class Tag(BaseModel):
171-
name = models.CharField(max_length=255, null=True)
172-
173-
COLORS = (
174-
("default", "Default Color"),
175-
("teamcolor", "Current Team Color"),
176-
("red", "Red"),
177-
("lightred", "Lighter Red"),
178-
("darkred", "Darker Red"),
179-
("bluegrey", "Blueish Grey"),
180-
("blue", "Blue"),
181-
("darkblue", "Darker Blue"),
182-
("purple", "Purple"),
183-
("orchid", "Orchid"),
184-
("yellow", "Yellow"),
185-
("gold", "Gold"),
186-
("lightgreen", "Lighter Green"),
187-
("green", "Green"),
188-
("lime", "Lime"),
189-
("grey", "Grey"),
190-
("darkgrey", "Darker Grey"),
191-
)
192-
193-
# colors
194-
chat = models.CharField(max_length=10, choices=COLORS, default="default")
195-
name = models.CharField(max_length=10, choices=COLORS, default="default")
196-
197-
# nametag
198-
base = models.CharField(max_length=10, choices=COLORS, default="default")
199-
200-
201201
class ServerGroup(BaseModel):
202202
name = models.CharField(max_length=255)
203203
flags = models.OneToOneField(ServerPermission, on_delete=models.CASCADE)

interface/templates/partials/admin/user.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
span= data.server|truncatechars:18
2525
.column.icon.username.pure-u-3-24
2626
.spacer
27-
- if data.role != 'root'
27+
- if not data.is_superuser
2828
- if perms.core.change_user
2929
.action
3030
i.animate.opacity.animated(data-feather="edit-2", onclick="window.api.edit('admin__administrator', this)")

panel/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@
6868
)
6969

7070
DEMO = False
71+
ROOT = "root"

0 commit comments

Comments
 (0)