mirror of
https://github.com/RPCS3/rpcs3-www.git
synced 2025-02-17 00:07:36 +00:00
Added reinitdb-compat command
* reinitdb-compat: It allows to reset the compatibility list using a CSV file. * Improved view for /compat/
This commit is contained in:
parent
9deb084422
commit
e470051895
1
.gitignore
vendored
1
.gitignore
vendored
@ -39,3 +39,4 @@ sqlite3.exe
|
||||
# Irrelevant files
|
||||
settings_secret.py
|
||||
db.sqlite3
|
||||
compatibility.csv
|
||||
|
5
deploy/reinitdb.py
Normal file
5
deploy/reinitdb.py
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
|
||||
os.system("python ../manage.py reinitdb-compat compatibility.csv")
|
||||
#os.system("python ../manage.py reinitdb-blog blog.xml")
|
@ -43,6 +43,9 @@
|
||||
<Compile Include="website\blog\views.py" />
|
||||
<Compile Include="website\blog\__init__.py" />
|
||||
<Compile Include="website\compat\admin.py" />
|
||||
<Compile Include="website\compat\management\commands\reinitdb-compat.py" />
|
||||
<Compile Include="website\compat\management\commands\__init__.py" />
|
||||
<Compile Include="website\compat\management\__init__.py" />
|
||||
<Compile Include="website\compat\models.py" />
|
||||
<Compile Include="website\compat\tests.py" />
|
||||
<Compile Include="website\compat\urls.py" />
|
||||
@ -76,6 +79,8 @@
|
||||
<Folder Include="website\blog\" />
|
||||
<Folder Include="website\blog\templates\" />
|
||||
<Folder Include="website\compat\" />
|
||||
<Folder Include="website\compat\management\" />
|
||||
<Folder Include="website\compat\management\commands\" />
|
||||
<Folder Include="website\compat\templates\" />
|
||||
<Folder Include="website\home\" />
|
||||
<Folder Include="website\home\templates\" />
|
||||
|
@ -6,19 +6,19 @@
|
||||
<div>
|
||||
<h2>
|
||||
<a href="/blog/{{ entry.get_url }}" title="{{ entry.title }}" rel="bookmark">
|
||||
{{ entry.title }}
|
||||
</a>
|
||||
</h2>
|
||||
{{ entry.title }}
|
||||
</a>
|
||||
</h2>
|
||||
<p>
|
||||
Written by
|
||||
<span><a href="#" rel="author">RPCS3 Staff</a></span>
|
||||
on
|
||||
<abbr class="published" title="{{ entry.date|date:"c" }}">{{ entry.date|date:"F j, Y" }}</abbr>
|
||||
<abbr class="published" title="{{ entry.date|date:" c" }}">{{ entry.date|date:"F j, Y" }}</abbr>
|
||||
/
|
||||
{% for tag in entry.tags.all %}
|
||||
{% for tag in entry.tags.all %}
|
||||
<span class="label label-default">{{ tag.tag }}</span>
|
||||
{% endfor %}
|
||||
/
|
||||
{% endfor %}
|
||||
/
|
||||
<a href="/blog/{{ entry.id }}/" title="Short URL to {{ entry.title }}" rel="shortlink">Short link</a>
|
||||
</p>
|
||||
</div>
|
||||
@ -31,9 +31,9 @@
|
||||
|
||||
<div class="text-center">
|
||||
<ul class="pagination">
|
||||
{% for num in pages %}
|
||||
{% for num in pages %}
|
||||
<li><a href='/blog/page/{{ num }}/'>{{ num }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
0
website/compat/management/__init__.py
Normal file
0
website/compat/management/__init__.py
Normal file
0
website/compat/management/commands/__init__.py
Normal file
0
website/compat/management/commands/__init__.py
Normal file
33
website/compat/management/commands/reinitdb-compat.py
Normal file
33
website/compat/management/commands/reinitdb-compat.py
Normal file
@ -0,0 +1,33 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from datetime import datetime
|
||||
from website.compat.models import Game
|
||||
|
||||
class Command(BaseCommand):
|
||||
args = "<file>"
|
||||
help = "Deletes the compatibility database and restarts it from the given CSV backup."
|
||||
|
||||
def handle(self, *args, **options):
|
||||
f = open(args[0], 'r')
|
||||
|
||||
for line in f.readlines():
|
||||
# Manually parsing the CSV file, don't try this at home!
|
||||
fields = line[:-1].split(",")
|
||||
for i in xrange(len(fields)):
|
||||
if fields[i].startswith('"') and fields[i].endswith('"'):
|
||||
fields[i] = fields[i][1:-1]
|
||||
if i == 5:
|
||||
try:
|
||||
fields[i] = datetime.strptime(fields[i], "%Y-%m-%d")
|
||||
except:
|
||||
# If there is no specific release date, choose PS3's release date
|
||||
fields[i] = datetime.strptime("2006-06-11", "%Y-%m-%d")
|
||||
|
||||
# Create and save the object
|
||||
game = Game(
|
||||
titleid=fields[0], name=fields[1], publisher=fields[2], developer=fields[3],
|
||||
genre=fields[4], release=fields[5], firmware=fields[6], compatibility=fields[7],
|
||||
)
|
||||
game.save()
|
||||
|
||||
f.close()
|
@ -5,7 +5,7 @@ from website.constants import *
|
||||
class Game(models.Model):
|
||||
# Static
|
||||
titleid = models.CharField(max_length=9, primary_key=True)
|
||||
name = models.CharField(max_length=64)
|
||||
name = models.CharField(max_length=128)
|
||||
publisher = models.CharField(max_length=64)
|
||||
developer = models.CharField(max_length=64)
|
||||
genre = models.CharField(max_length=32)
|
||||
|
@ -10,45 +10,15 @@
|
||||
<div class='col-md-4'>
|
||||
<h3>Stats</h3>
|
||||
<dl>
|
||||
<dt>Perfect: {{ strResults.0 }} %</dt>
|
||||
{% for result in results %}
|
||||
<dt>{{ result.category }}: {{ result.string }} %</dt>
|
||||
<dd>
|
||||
<div class='progress'>
|
||||
<div class='progress-bar' role='progressbar' aria-valuenow='{{ intResults.0 }}' aria-valuemin='0' aria-valuemax='100' style='width: {{ strResults.0 }}%'>
|
||||
</div>
|
||||
</div>
|
||||
</dd>
|
||||
|
||||
<dt>Playable: {{ strResults.1 }} %</dt>
|
||||
<dd>
|
||||
<div class='progress'>
|
||||
<div class='progress-bar progress-bar-success' role='progressbar' aria-valuenow='{{ intResults.1 }}' aria-valuemin='0' aria-valuemax='100' style='width:{{ strResults.1 }}%;'>
|
||||
</div>
|
||||
</div>
|
||||
</dd>
|
||||
|
||||
<dt>Ingame: {{ strResults.2 }} %</dt>
|
||||
<dd>
|
||||
<div class='progress'>
|
||||
<div class='progress-bar progress-bar-warning' role='progressbar' aria-valuenow='{{ intResults.2 }}' aria-valuemin='0' aria-valuemax='100' style='width:{{ strResults.2 }}%;'>
|
||||
</div>
|
||||
</div>
|
||||
</dd>
|
||||
|
||||
<dt>Intro: {{ strResults.3 }} %</dt>
|
||||
<dd>
|
||||
<div class='progress'>
|
||||
<div class='progress-bar progress-bar-danger' role='progressbar' aria-valuenow='{{ intResults.3 }}' aria-valuemin='0' aria-valuemax='100' style='width:{{ strResults.3 }}%;'>
|
||||
</div>
|
||||
</div>
|
||||
</dd>
|
||||
|
||||
<dt>Nothing: {{ strResults.4 }} %</dt>
|
||||
<dd>
|
||||
<div class='progress'>
|
||||
<div class='progress-bar' role='progressbar' aria-valuenow='{{ intResults.4 }}' aria-valuemin='0' aria-valuemax='100' style='width:{{ strResults.4 }}%; background-color: #555'>
|
||||
<div class='progress-bar' role='progressbar' aria-valuenow='{{ result.int }}' aria-valuemin='0' aria-valuemax='100' style='width:{{ result.string }}%; background-color:{{ result.color }}'>
|
||||
</div>
|
||||
</div>
|
||||
</dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
@ -14,12 +14,19 @@ def compat_index(request):
|
||||
len(Game.objects.filter(compatibility=C.COMPATIBILITY_PERFECT)),
|
||||
]
|
||||
total = sum(stats)
|
||||
strResults = map(lambda x: '%.2f' % (100.0*x/total if total else 0), stats)
|
||||
intResults = map(lambda x: 100*x/total if total else 0, stats)
|
||||
|
||||
# TODO: Rewrite this with more Django style
|
||||
results = []
|
||||
for i in range(len(stats))[::-1]:
|
||||
results.append({
|
||||
'category' : C.COMPATIBILITY[i+1][1], # e.g. 'Playable'
|
||||
'string' : '%.2f' % (100.0 * stats[i] / total if total else 0), # e.g. '12.34'
|
||||
'int' : 100 * stats[i] / total if total else 0, # e.g. 12
|
||||
'color' : ['#555555', '#D9534F', '#F0AD4E', '#5CB85C', '#428BCA'][i], # e.g. '#5CB85C'
|
||||
})
|
||||
|
||||
objects = {
|
||||
'strResults' : strResults,
|
||||
'intResults' : intResults,
|
||||
'results' : results,
|
||||
'chars' : '#ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
}
|
||||
return render(request, 'index.html', objects)
|
||||
|
Loading…
x
Reference in New Issue
Block a user