Added attraction location type

doc_update
Joey Hines 2019-05-12 11:23:59 -05:00
parent 985dd17dc0
commit 682faca893
9 changed files with 138 additions and 8 deletions

View File

@ -210,6 +210,23 @@ def add_market(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Market) return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Market)
@command("POST")
def add_market(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None):
"""
:request: POST
:param x_pos: MC X Coordinate
:param z_pos: MC Z Coordinate
:param name: Market Name (If None, Defaults to Player's Attraction)
:param discord_uuid: Discord UUID
:param mc_uuid: Minecraft UUID
:return: JSON representation of the attraction
:raises: EntryNameNotUniqueError, PlayerNotFound, LocationLookupError
:help: Adds your attraction to the database.
"""
return add_location(x_pos, z_pos, name=name, discord_uuid=discord_uuid, mc_uuid=mc_uuid, loc_type=Attraction)
@command("POST") @command("POST")
def add_tunnel(tunnel_direction, tunnel_number, location_name=None, discord_uuid=None, mc_uuid=None): def add_tunnel(tunnel_direction, tunnel_number, location_name=None, discord_uuid=None, mc_uuid=None):
""" """

View File

@ -1,5 +1,6 @@
# Generated by Django 2.1.2 on 2018-10-26 22:05 # Generated by Django 2.1.2 on 2019-05-12 16:15
import GeoffreyApp.util
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
@ -12,6 +13,15 @@ class Migration(migrations.Migration):
] ]
operations = [ operations = [
migrations.CreateModel(
name='APIToken',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('key', models.CharField(default=GeoffreyApp.util.create_token, max_length=25, unique=True)),
('name', models.CharField(blank=True, max_length=50)),
('commands_perm', models.BooleanField(default=False)),
],
),
migrations.CreateModel( migrations.CreateModel(
name='ItemListing', name='ItemListing',
fields=[ fields=[
@ -19,6 +29,7 @@ class Migration(migrations.Migration):
('item_name', models.CharField(max_length=128)), ('item_name', models.CharField(max_length=128)),
('price', models.IntegerField()), ('price', models.IntegerField()),
('amount', models.IntegerField()), ('amount', models.IntegerField()),
('date_restocked', models.DateTimeField(auto_now=True)),
], ],
), ),
migrations.CreateModel( migrations.CreateModel(
@ -35,9 +46,16 @@ class Migration(migrations.Migration):
name='Player', name='Player',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30)), ('name', models.CharField(max_length=30, unique=True)),
('mc_uuid', models.CharField(max_length=36)), ('mc_uuid', models.CharField(max_length=36, unique=True)),
('discord_uuid', models.CharField(max_length=50)), ('discord_uuid', models.CharField(max_length=50, unique=True)),
],
),
migrations.CreateModel(
name='Resource',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('resource_name', models.CharField(max_length=128)),
], ],
), ),
migrations.CreateModel( migrations.CreateModel(
@ -45,9 +63,16 @@ class Migration(migrations.Migration):
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('tunnel_number', models.IntegerField()), ('tunnel_number', models.IntegerField()),
('tunnel_direction', models.CharField(choices=[('N', 'North'), ('E', 'East'), ('S', ''), ('W', '')], max_length=1)), ('tunnel_direction', models.CharField(choices=[('N', 'North'), ('E', 'East'), ('S', 'South'), ('W', 'West')], max_length=1)),
], ],
), ),
migrations.CreateModel(
name='Attraction',
fields=[
('location_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='GeoffreyApp.Location')),
],
bases=('GeoffreyApp.location',),
),
migrations.CreateModel( migrations.CreateModel(
name='Base', name='Base',
fields=[ fields=[
@ -55,6 +80,27 @@ class Migration(migrations.Migration):
], ],
bases=('GeoffreyApp.location',), bases=('GeoffreyApp.location',),
), ),
migrations.CreateModel(
name='Market',
fields=[
('location_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='GeoffreyApp.Location')),
],
bases=('GeoffreyApp.location',),
),
migrations.CreateModel(
name='PointOfInterest',
fields=[
('location_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='GeoffreyApp.Location')),
],
bases=('GeoffreyApp.location',),
),
migrations.CreateModel(
name='PublicFarm',
fields=[
('location_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='GeoffreyApp.Location')),
],
bases=('GeoffreyApp.location',),
),
migrations.CreateModel( migrations.CreateModel(
name='Shop', name='Shop',
fields=[ fields=[
@ -62,6 +108,14 @@ class Migration(migrations.Migration):
], ],
bases=('GeoffreyApp.location',), bases=('GeoffreyApp.location',),
), ),
migrations.CreateModel(
name='Town',
fields=[
('location_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='GeoffreyApp.Location')),
('residents', models.ManyToManyField(to='GeoffreyApp.Player')),
],
bases=('GeoffreyApp.location',),
),
migrations.AddField( migrations.AddField(
model_name='tunnel', model_name='tunnel',
name='location', name='location',
@ -70,7 +124,12 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='location', model_name='location',
name='owner', name='owner',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='owner_player', to='GeoffreyApp.Player'), field=models.ManyToManyField(to='GeoffreyApp.Player'),
),
migrations.AddField(
model_name='resource',
name='farm',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='resource', to='GeoffreyApp.PublicFarm'),
), ),
migrations.AddField( migrations.AddField(
model_name='itemlisting', model_name='itemlisting',

View File

@ -15,7 +15,7 @@ class Migration(migrations.Migration):
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
( (
'key', models.CharField(default=GeoffreyApp.GeoffreyApp.util.create_token, max_length=25, unique=True)), 'key', models.CharField(default=GeoffreyApp.util.create_token, max_length=25, unique=True)),
('name', models.CharField(blank=True, max_length=50)), ('name', models.CharField(blank=True, max_length=50)),
], ],
), ),

View File

@ -0,0 +1,20 @@
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('GeoffreyApp', '0010_pointofinterest'),
]
operations = [
migrations.CreateModel(
name='Attraction',
fields=[
('location_ptr',
models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True,
primary_key=True, serialize=False, to='GeoffreyApp.Location')),
],
bases=('GeoffreyApp.location',),
),
]

View File

@ -260,6 +260,7 @@ class Base(Location):
info_page = "GeoffreyBaseInfo" info_page = "GeoffreyBaseInfo"
class Town(Location): class Town(Location):
info_page = "GeoffreyTownInfo" info_page = "GeoffreyTownInfo"
@ -348,6 +349,10 @@ class PublicFarm(Location):
info_page = "GeoffreyPublicFarmInfo" info_page = "GeoffreyPublicFarmInfo"
class Attraction(Location):
info_page = "GeoffreyAttractionInfo"
class Resource(models.Model): class Resource(models.Model):
farm = models.ForeignKey(PublicFarm, related_name="resource", on_delete=models.CASCADE) farm = models.ForeignKey(PublicFarm, related_name="resource", on_delete=models.CASCADE)
resource_name = models.CharField(max_length=128) resource_name = models.CharField(max_length=128)

View File

@ -0,0 +1,9 @@
{% extends "GeoffreyApp/base.html" %}
{% block header %}
Attractions
{% endblock %}
{% block content %}
{% include "GeoffreyApp/location_table.html" with loc_list=attraction_list show_owner=True %}
{% endblock %}

View File

@ -12,7 +12,8 @@ navbar_options = {
"ItemListing": ["Item Listings", reverse("GeoffreyItems")], "ItemListing": ["Item Listings", reverse("GeoffreyItems")],
"PublicFarm": ["Public Farms", reverse("GeoffreyPublicFarms")], "PublicFarm": ["Public Farms", reverse("GeoffreyPublicFarms")],
"Market": ["Markets", reverse("GeoffreyMarkets")], "Market": ["Markets", reverse("GeoffreyMarkets")],
"PointOfInterest": ["Points of Interest", reverse("GeoffreyPointOfInterest")] "PointOfInterest": ["Points of Interest", reverse("GeoffreyPointOfInterest")],
"Attractions": ["Attractions", reverse("GeoffreyAttraction")]
} }
option_format = '<li class="nav-item{}"> <a class="nav-link" href="{}">{} </a> </li>' option_format = '<li class="nav-item{}"> <a class="nav-link" href="{}">{} </a> </li>'

View File

@ -21,6 +21,9 @@ urlpatterns = [
url(r'^pointofinterest/$', views.PointOfInterestList.as_view(), name='GeoffreyPointOfInterest'), url(r'^pointofinterest/$', views.PointOfInterestList.as_view(), name='GeoffreyPointOfInterest'),
url(r'^pointofinterest/(?P<id>[0-9]{1,9})/$', views.PointOfInterestInfo.as_view(), url(r'^pointofinterest/(?P<id>[0-9]{1,9})/$', views.PointOfInterestInfo.as_view(),
name='GeoffreyPointOfInterestInfo'), name='GeoffreyPointOfInterestInfo'),
url(r'^attraction/$', views.AttractionList.as_view(), name='GeoffreyAttraction'),
url(r'^attraction/(?P<id>[0-9]{1,9})/$', views.AttractionInfo.as_view(),
name='AttractionInfo'),
path('api/', include('GeoffreyApp.api.urls')), path('api/', include('GeoffreyApp.api.urls')),
] ]

View File

@ -86,6 +86,9 @@ class MarketList(GeoffreyModelList):
class PointOfInterestList(GeoffreyModelList): class PointOfInterestList(GeoffreyModelList):
model = PointOfInterest model = PointOfInterest
class AttractionList(GeoffreyModelList):
model = Attraction
class ModelInfoView(View): class ModelInfoView(View):
template = None template = None
@ -202,3 +205,16 @@ class PointOfInterestInfo(ModelInfoView):
} }
return context return context
class AttractionInfo(ModelInfoView):
template = "location.html"
def get_context(self, id):
attraction = Attraction.objects.get(pk=id)
context = {
"loc": attraction
}
return context