mirror of
https://github.com/Findus23/RPGnotes.git
synced 2024-09-19 15:43:45 +02:00
basic location
This commit is contained in:
parent
735f7bc41d
commit
61c4193901
25 changed files with 212 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
{% extends 'navbarbase.html' %}
|
||||
{% extends 'tenantbase.html' %}
|
||||
{% load django_bootstrap5 %}
|
||||
{% load static %}
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{% extends "navbarbase.html" %}
|
||||
{% extends "tenantbase.html" %}
|
||||
|
||||
{% block content %}
|
||||
{{ object }}
|
||||
<h1>{{ object }}</h1>
|
||||
<ul>
|
||||
{% for user in users %}
|
||||
<li>{{ user }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
|
@ -34,14 +34,19 @@ class CampaignCreateView(LoginRequiredMixin, generic.FormView):
|
|||
return redirect("http://" + fqdn)
|
||||
|
||||
|
||||
class CampaignDetailView(PartOfTenantRequiredMixin,LoginRequiredMixin, generic.DetailView):
|
||||
class CampaignDetailView(PartOfTenantRequiredMixin, LoginRequiredMixin, generic.DetailView):
|
||||
template_name = "campaigns/campaign_detail.html"
|
||||
model = Campaign
|
||||
slug_url_kwarg = "campslug"
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
def get_object(self, queryset=None) -> Campaign:
|
||||
return self.request.tenant
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CampaignDetailView, self).get_context_data(**kwargs)
|
||||
context["users"] = self.get_object().user_set.all()
|
||||
return context
|
||||
|
||||
|
||||
class CampaignEditView(LoginRequiredMixin, generic.UpdateView):
|
||||
template_name = "campaigns/campaign_edit.html"
|
||||
|
|
|
@ -6,4 +6,4 @@ from characters.models import Character
|
|||
class CharacterForm(ModelForm):
|
||||
class Meta:
|
||||
model = Character
|
||||
fields = ["name", "description_md", "subtitle", "player", "color", "image"]
|
||||
fields = ["name", "description_md", "subtitle", "player", "location", "color", "image"]
|
||||
|
|
25
characters/migrations/0003_auto_20210906_2011.py
Normal file
25
characters/migrations/0003_auto_20210906_2011.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 3.2.7 on 2021-09-06 18:11
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('locations', '0001_initial'),
|
||||
('characters', '0002_auto_20210829_2220'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='character',
|
||||
name='location',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='locations.location'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='historicalcharacter',
|
||||
name='location',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='locations.location'),
|
||||
),
|
||||
]
|
|
@ -6,6 +6,7 @@ from simple_history.models import HistoricalRecords
|
|||
from sorl.thumbnail import ImageField
|
||||
|
||||
from common.models import BaseModel, DescriptionModel
|
||||
from locations.models import Location
|
||||
from rpg_notes.settings import AUTH_USER_MODEL
|
||||
from utils.colors import get_random_color, is_bright_color
|
||||
|
||||
|
@ -19,7 +20,7 @@ class Character(BaseModel, DescriptionModel):
|
|||
subtitle = models.CharField(max_length=100, blank=True)
|
||||
player = models.ForeignKey(AUTH_USER_MODEL, on_delete=models.PROTECT, blank=True, null=True)
|
||||
# faction = models.ForeignKey(Faction, on_delete=models.PROTECT, blank=True, null=True)
|
||||
# location = models.ForeignKey(Location, on_delete=models.PROTECT, blank=True, null=True)
|
||||
location = models.ForeignKey(Location, on_delete=models.PROTECT, blank=True, null=True)
|
||||
color = models.CharField(max_length=7, default=get_random_color, validators=[
|
||||
MinLengthValidator(7),
|
||||
validate_color_hex
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "navbarbase.html" %}
|
||||
{% extends "tenantbase.html" %}
|
||||
{% load thumbutils %}
|
||||
{% load thumbnail %}
|
||||
{% load humanize %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "navbarbase.html" %}
|
||||
{% extends "tenantbase.html" %}
|
||||
{% load thumbutils %}
|
||||
{% load thumbnail %}
|
||||
{% load humanize %}
|
||||
|
|
0
locations/__init__.py
Normal file
0
locations/__init__.py
Normal file
6
locations/admin.py
Normal file
6
locations/admin.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from locations.models import Location
|
||||
|
||||
admin.site.register(Location)
|
6
locations/apps.py
Normal file
6
locations/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class LocationsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'locations'
|
29
locations/migrations/0001_initial.py
Normal file
29
locations/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Generated by Django 3.2.7 on 2021-09-06 18:11
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Location',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('description_md', models.TextField(blank=True)),
|
||||
('description_html', models.TextField(blank=True, editable=False)),
|
||||
('name', models.CharField(max_length=1000)),
|
||||
('slug', models.SlugField(editable=False, unique=True)),
|
||||
('part_of', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.RESTRICT, to='locations.location')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
0
locations/migrations/__init__.py
Normal file
0
locations/migrations/__init__.py
Normal file
8
locations/models.py
Normal file
8
locations/models.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
from common.models import BaseModel, DescriptionModel
|
||||
|
||||
|
||||
class Location(BaseModel, DescriptionModel):
|
||||
part_of = models.ForeignKey("self", on_delete=models.RESTRICT, null=True, blank=True)
|
57
locations/templates/locations/detail.html
Normal file
57
locations/templates/locations/detail.html
Normal file
|
@ -0,0 +1,57 @@
|
|||
{% extends "tenantbase.html" %}
|
||||
{% load thumbutils %}
|
||||
{% load thumbnail %}
|
||||
{% load humanize %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<ul class="nav nav-pills flex-column">
|
||||
{% for c in player_characters %}
|
||||
{% include "macros/character-pillar.html" with character=c %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<ul class="nav nav-pills flex-column">
|
||||
{% for c in npcs %}
|
||||
{% include "macros/character-pillar.html" with character=c %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<a class="btn btn-primary" href="{% url "characteradd" %}">Add Character</a>
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<div class="character-heading" style="border-bottom-color: {{ character.color }}">
|
||||
{% if character.image %}
|
||||
{% thumbnail character.image "150x150" crop="center" as im %}
|
||||
<a href="{{ character.image.url }}" target="_blank">
|
||||
<img class="avatar avatar-image avatar-large rounded-circle" src="{{ im.url }}" width="{{ im.width }}"
|
||||
height="{{ im.height }}"
|
||||
srcset="{{ im.url|srcset }}">
|
||||
</a>
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<div class="avatar avatar-text avatar-large"
|
||||
style="background: {{ character.color }};color:{{ character.text_color }}">{{ character.initials }}</div>
|
||||
{% endif %}
|
||||
|
||||
<h1>
|
||||
{{ character.name }}
|
||||
<a href="{% url "characteredit" character.slug %}">
|
||||
edit
|
||||
</a>
|
||||
</h1>
|
||||
<p>{{ character.subtitle }}</p>
|
||||
</div>
|
||||
<dl>
|
||||
{% if character.player %}
|
||||
<dt>Player:</dt>
|
||||
<dd>{{ character.player }}</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
{{ character.description_html|safe }}
|
||||
|
||||
<div>
|
||||
<small>Last updated: {{ character.last_modified|naturaltime }} by {{ character.history.first.history_user }} </small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
3
locations/tests.py
Normal file
3
locations/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
locations/views.py
Normal file
3
locations/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
|
@ -6,4 +6,4 @@ from loot.models import Loot
|
|||
class LootForm(ModelForm):
|
||||
class Meta:
|
||||
model = Loot
|
||||
fields = ["name", "description_md", "quantity", "value_gold", "owner", "magic_item"]
|
||||
fields = ["name", "description_md", "quantity", "value_gold", "owner", "location", "magic_item"]
|
||||
|
|
25
loot/migrations/0002_auto_20210906_2011.py
Normal file
25
loot/migrations/0002_auto_20210906_2011.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 3.2.7 on 2021-09-06 18:11
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('locations', '0001_initial'),
|
||||
('loot', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='historicalloot',
|
||||
name='location',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='locations.location'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='loot',
|
||||
name='location',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='locations.location'),
|
||||
),
|
||||
]
|
|
@ -3,6 +3,7 @@ from simple_history.models import HistoricalRecords
|
|||
|
||||
from characters.models import Character
|
||||
from common.models import DescriptionModel
|
||||
from locations.models import Location
|
||||
|
||||
|
||||
class Loot(DescriptionModel):
|
||||
|
@ -10,6 +11,7 @@ class Loot(DescriptionModel):
|
|||
quantity = models.PositiveSmallIntegerField()
|
||||
value_gold = models.DecimalField("Value (Gold)", max_digits=7, decimal_places=2)
|
||||
owner = models.ForeignKey(Character, on_delete=models.PROTECT, blank=True, null=True)
|
||||
location = models.ForeignKey(Location, on_delete=models.PROTECT, blank=True, null=True)
|
||||
magic_item = models.BooleanField(default=False)
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
last_modified = models.DateTimeField(auto_now=True)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends 'navbarbase.html' %}
|
||||
{% extends 'tenantbase.html' %}
|
||||
{% load django_bootstrap5 %}
|
||||
{% load static %}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "navbarbase.html" %}
|
||||
{% extends "tenantbase.html" %}
|
||||
{% load formatters %}
|
||||
|
||||
{% block heading %}
|
||||
|
@ -12,6 +12,7 @@
|
|||
<td>Quantity</td>
|
||||
<td>Total Value</td>
|
||||
<td>Owner</td>
|
||||
<td>Location</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -25,6 +26,7 @@
|
|||
<td>{{ l.quantity }}</td>
|
||||
<td>{{ l.value_gold|format_money_html }}</td>
|
||||
<td>{{ l.owner }}</td>
|
||||
<td>{{ l.location }}</td>
|
||||
<td>
|
||||
<svg class="chev" viewBox="0 0 640 1024" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M512 320L320 512 128 320 0 448l320 320 320-320L512 320z"/>
|
||||
|
|
|
@ -56,6 +56,7 @@ TENANT_APPS = (
|
|||
'tenant_users.permissions', # Defined in both shared apps and tenant apps
|
||||
'django.contrib.admin',
|
||||
|
||||
'locations',
|
||||
'characters',
|
||||
'loot',
|
||||
'days',
|
||||
|
@ -176,6 +177,6 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|||
|
||||
THUMBNAIL_ALTERNATIVE_RESOLUTIONS = [2, 3]
|
||||
|
||||
ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window
|
||||
ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window
|
||||
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
|
|
|
@ -32,4 +32,7 @@
|
|||
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
<footer>
|
||||
<a href="{% url "logout" %}">Logout</a>
|
||||
</footer>
|
||||
{% endblock %}
|
18
users/migrations/0002_alter_tenantuser_name.py
Normal file
18
users/migrations/0002_alter_tenantuser_name.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.7 on 2021-09-06 18:10
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='tenantuser',
|
||||
name='name',
|
||||
field=models.CharField(max_length=100, verbose_name='Name'),
|
||||
),
|
||||
]
|
Loading…
Reference in a new issue