Added attraction location type
parent
985dd17dc0
commit
682faca893
|
@ -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)
|
||||
|
||||
|
||||
@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")
|
||||
def add_tunnel(tunnel_direction, tunnel_number, location_name=None, discord_uuid=None, mc_uuid=None):
|
||||
"""
|
||||
|
|
|
@ -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
|
||||
import django.db.models.deletion
|
||||
|
||||
|
@ -12,6 +13,15 @@ class Migration(migrations.Migration):
|
|||
]
|
||||
|
||||
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(
|
||||
name='ItemListing',
|
||||
fields=[
|
||||
|
@ -19,6 +29,7 @@ class Migration(migrations.Migration):
|
|||
('item_name', models.CharField(max_length=128)),
|
||||
('price', models.IntegerField()),
|
||||
('amount', models.IntegerField()),
|
||||
('date_restocked', models.DateTimeField(auto_now=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
|
@ -35,9 +46,16 @@ class Migration(migrations.Migration):
|
|||
name='Player',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=30)),
|
||||
('mc_uuid', models.CharField(max_length=36)),
|
||||
('discord_uuid', models.CharField(max_length=50)),
|
||||
('name', models.CharField(max_length=30, unique=True)),
|
||||
('mc_uuid', models.CharField(max_length=36, unique=True)),
|
||||
('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(
|
||||
|
@ -45,9 +63,16 @@ class Migration(migrations.Migration):
|
|||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('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(
|
||||
name='Base',
|
||||
fields=[
|
||||
|
@ -55,6 +80,27 @@ class Migration(migrations.Migration):
|
|||
],
|
||||
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(
|
||||
name='Shop',
|
||||
fields=[
|
||||
|
@ -62,6 +108,14 @@ class Migration(migrations.Migration):
|
|||
],
|
||||
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(
|
||||
model_name='tunnel',
|
||||
name='location',
|
||||
|
@ -70,7 +124,12 @@ class Migration(migrations.Migration):
|
|||
migrations.AddField(
|
||||
model_name='location',
|
||||
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(
|
||||
model_name='itemlisting',
|
||||
|
|
|
@ -15,7 +15,7 @@ class Migration(migrations.Migration):
|
|||
fields=[
|
||||
('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)),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -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',),
|
||||
),
|
||||
]
|
|
@ -260,6 +260,7 @@ class Base(Location):
|
|||
info_page = "GeoffreyBaseInfo"
|
||||
|
||||
|
||||
|
||||
class Town(Location):
|
||||
info_page = "GeoffreyTownInfo"
|
||||
|
||||
|
@ -348,6 +349,10 @@ class PublicFarm(Location):
|
|||
info_page = "GeoffreyPublicFarmInfo"
|
||||
|
||||
|
||||
class Attraction(Location):
|
||||
info_page = "GeoffreyAttractionInfo"
|
||||
|
||||
|
||||
class Resource(models.Model):
|
||||
farm = models.ForeignKey(PublicFarm, related_name="resource", on_delete=models.CASCADE)
|
||||
resource_name = models.CharField(max_length=128)
|
||||
|
|
|
@ -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 %}
|
|
@ -12,7 +12,8 @@ navbar_options = {
|
|||
"ItemListing": ["Item Listings", reverse("GeoffreyItems")],
|
||||
"PublicFarm": ["Public Farms", reverse("GeoffreyPublicFarms")],
|
||||
"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>'
|
||||
|
|
|
@ -21,6 +21,9 @@ urlpatterns = [
|
|||
url(r'^pointofinterest/$', views.PointOfInterestList.as_view(), name='GeoffreyPointOfInterest'),
|
||||
url(r'^pointofinterest/(?P<id>[0-9]{1,9})/$', views.PointOfInterestInfo.as_view(),
|
||||
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')),
|
||||
]
|
||||
|
||||
|
|
|
@ -86,6 +86,9 @@ class MarketList(GeoffreyModelList):
|
|||
class PointOfInterestList(GeoffreyModelList):
|
||||
model = PointOfInterest
|
||||
|
||||
class AttractionList(GeoffreyModelList):
|
||||
model = Attraction
|
||||
|
||||
|
||||
class ModelInfoView(View):
|
||||
template = None
|
||||
|
@ -202,3 +205,16 @@ class PointOfInterestInfo(ModelInfoView):
|
|||
}
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class AttractionInfo(ModelInfoView):
|
||||
template = "location.html"
|
||||
|
||||
def get_context(self, id):
|
||||
attraction = Attraction.objects.get(pk=id)
|
||||
|
||||
context = {
|
||||
"loc": attraction
|
||||
}
|
||||
|
||||
return context
|
Loading…
Reference in New Issue