diff --git a/GeoffreyApp/api/commands.py b/GeoffreyApp/api/commands.py index 2e49712..10ae76d 100644 --- a/GeoffreyApp/api/commands.py +++ b/GeoffreyApp/api/commands.py @@ -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): """ diff --git a/GeoffreyApp/migrations/0001_initial.py b/GeoffreyApp/migrations/0001_initial.py index 79d23ab..c2d68d7 100644 --- a/GeoffreyApp/migrations/0001_initial.py +++ b/GeoffreyApp/migrations/0001_initial.py @@ -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', diff --git a/GeoffreyApp/migrations/0003_apitoken.py b/GeoffreyApp/migrations/0003_apitoken.py index e024438..0d7e18c 100644 --- a/GeoffreyApp/migrations/0003_apitoken.py +++ b/GeoffreyApp/migrations/0003_apitoken.py @@ -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)), ], ), diff --git a/GeoffreyApp/migrations/0011_attraction.py b/GeoffreyApp/migrations/0011_attraction.py new file mode 100644 index 0000000..fdc6b8e --- /dev/null +++ b/GeoffreyApp/migrations/0011_attraction.py @@ -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',), + ), + ] \ No newline at end of file diff --git a/GeoffreyApp/models.py b/GeoffreyApp/models.py index 837655b..88378be 100644 --- a/GeoffreyApp/models.py +++ b/GeoffreyApp/models.py @@ -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) diff --git a/GeoffreyApp/templates/GeoffreyApp/attraction_list.html b/GeoffreyApp/templates/GeoffreyApp/attraction_list.html new file mode 100644 index 0000000..f9e1de5 --- /dev/null +++ b/GeoffreyApp/templates/GeoffreyApp/attraction_list.html @@ -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 %} \ No newline at end of file diff --git a/GeoffreyApp/templatetags/navbar.py b/GeoffreyApp/templatetags/navbar.py index 6dde3c2..ba3c897 100644 --- a/GeoffreyApp/templatetags/navbar.py +++ b/GeoffreyApp/templatetags/navbar.py @@ -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 = '