Skip to content

Commit

Permalink
Merge pull request #113 from alameda-project/workspaces-enhancements-…
Browse files Browse the repository at this point in the history
…and-more

Workspaces enhancements and more
  • Loading branch information
matagus authored Feb 24, 2024
2 parents d2116c4 + 4c02606 commit c15af40
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 98 deletions.
90 changes: 0 additions & 90 deletions alameda/stories/fixtures/initial.json

This file was deleted.

2 changes: 1 addition & 1 deletion config/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
# Custom user app defaults
# Select the correct user model
AUTH_USER_MODEL = 'users.User'
LOGIN_REDIRECT_URL = 'stories:story-list'
LOGIN_REDIRECT_URL = '/'
LOGIN_URL = 'login'

# SLUGLIFIER
Expand Down
4 changes: 4 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from django.contrib.auth import views as auth_views
from django.views import defaults as default_views

from matorral.workspaces.views import redirect_to_workspace


urlpatterns = [
# Django Admin, use {% url 'admin:index' %}
Expand All @@ -30,6 +32,8 @@
path(r'<workspace>/', include('matorral.stories.urls', namespace='stories')),
path(r'<workspace>/sprints/', include('matorral.sprints.urls', namespace='sprints')),

path(r'', redirect_to_workspace, name='redirect_to_workspace')

] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

if settings.DEBUG:
Expand Down
17 changes: 17 additions & 0 deletions matorral/contrib/sites/migrations/0003_alter_site_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.10 on 2024-02-23 09:07

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('sites', '0002_set_site_domain_and_name'),
]

operations = [
migrations.AlterModelOptions(
name='site',
options={'ordering': ['domain'], 'verbose_name': 'site', 'verbose_name_plural': 'sites'},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.10 on 2024-02-23 09:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sprints', '0007_auto_20200815_1611'),
]

operations = [
migrations.AlterModelOptions(
name='historicalsprint',
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical sprint', 'verbose_name_plural': 'historical sprints'},
),
migrations.AlterField(
model_name='historicalsprint',
name='history_date',
field=models.DateTimeField(db_index=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.2.10 on 2024-02-23 09:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('stories', '0009_auto_20200816_1042'),
]

operations = [
migrations.AlterModelOptions(
name='historicalepic',
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical epic', 'verbose_name_plural': 'historical epics'},
),
migrations.AlterModelOptions(
name='historicalstory',
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical story', 'verbose_name_plural': 'historical stories'},
),
migrations.AlterField(
model_name='historicalepic',
name='history_date',
field=models.DateTimeField(db_index=True),
),
migrations.AlterField(
model_name='historicalstory',
name='history_date',
field=models.DateTimeField(db_index=True),
),
]
56 changes: 56 additions & 0 deletions matorral/stories/migrations/0011_auto_20240223_0910.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Generated by Django 4.2.10 on 2024-02-23 09:10

from django.db import migrations


story_slug_name_list = [
("pl", "Planning"),
("pr", "Prioritized & Ready"),
("ip", "In Progress"),
("qa", "In QA"),
("3p", "Waiting for 3rd Party"),
("dn", "Done"),
("wd", "Won't Do"),
]

epic_slug_name_list = [
("pl", "Planning"),
("pr", "Prioritized & Ready"),
("ip", "In Progress"),
("dn", "Done"),
]


def create_story_states(apps, schema_editor):
StoryState = apps.get_model("stories", "StoryState")

for slug, name in story_slug_name_list:
StoryState.objects.get_or_create(slug=slug, defaults={"name": name})

EpicState = apps.get_model("stories", "EpicState")

for slug, name in epic_slug_name_list:
EpicState.objects.get_or_create(slug=slug, defaults={"name": name})


def remove_story_states(apps, schema_editor):
StoryState = apps.get_model("stories", "StoryState")

for slug, _ in story_slug_name_list:
StoryState.objects.filter(slug=slug).delete()

EpicState = apps.get_model("stories", "EpicState")

for slug, _ in epic_slug_name_list:
EpicState.objects.filter(slug=slug).delete()


class Migration(migrations.Migration):

dependencies = [
('stories', '0010_alter_historicalepic_options_and_more'),
]

operations = [
migrations.RunPython(create_story_states, remove_story_states),
]
9 changes: 4 additions & 5 deletions matorral/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ <h1 class="title has-text-white-bis">
Stories
</a>

<a class="navbar-item" href="{% url 'workspaces:workspace-list' current_workspace %}">
Workspaces
</a>

<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">
More
Expand Down Expand Up @@ -85,6 +81,9 @@ <h1 class="title has-text-white-bis">
Admin
</a>
{% endif %}
<a class="navbar-item" href="{% url 'workspaces:workspace-list' current_workspace %}">
Workspaces
</a>
<a href="{% url 'logout' %}" class="navbar-item">
Logout
</a>
Expand Down Expand Up @@ -134,7 +133,7 @@ <h1 class="title has-text-white-bis">
<p>
<strong>Matorral</strong> by <a target="_blank" href="https://github.com/matagus">matagus</a>.
<p>
This website has been built in a few weekends thanks to <a target="_blank" href="https://bulma.io/">Bulma</a> &amp; <a target="_blank" href="https://www.djangoproject.com/">Django</a>.
Built with ❤️, <a target="_blank" href="https://bulma.io/">Bulma</a> &amp; <a target="_blank" href="https://www.djangoproject.com/">Django</a>.
</p>
</div>
</footer>
Expand Down
18 changes: 18 additions & 0 deletions matorral/users/migrations/0002_alter_user_first_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.10 on 2024-02-23 09:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('users', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='user',
name='first_name',
field=models.CharField(blank=True, max_length=150, verbose_name='first name'),
),
]
3 changes: 3 additions & 0 deletions matorral/workspaces/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def process_view(self, request, view_func, view_args, view_kwargs):
except KeyError:
return None

if not request.user.is_authenticated:
return None

queryset = (Workspace.objects.filter(owner=request.user) | Workspace.objects.filter(members=request.user)).distinct()

try:
Expand Down
10 changes: 10 additions & 0 deletions matorral/workspaces/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,13 @@ def post(self, *args, **kwargs):
form = self.get_form_class()(data, instance=self.get_object())

return self.form_valid(form)


@login_required
def redirect_to_workspace(request):
first_workspace = request.user.workspace_set.order_by('id').first()
return HttpResponseRedirect(
reverse_lazy(
'stories:story-list', kwargs={'workspace': first_workspace.slug}
)
)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extra-dependencies = [
server = "python manage.py runserver_plus --settings=config.settings.local"
shell = "python manage.py shell_plus --settings=config.settings.local"
migrate = "python manage.py migrate --settings=config.settings.local"
makemigrations = "python manage.py makemigrations --settings=config.settings.local"
makemigrations = "python manage.py makemigrations --settings=config.settings.local {args}"

# Production environment
[tool.hatch.envs.prod]
Expand All @@ -101,7 +101,7 @@ extra-dependencies = [
[tool.hatch.envs.prod.scripts]
server = "gunicorn config.wsgi:application --bind"
migrate = "python manage.py migrate --settings=config.settings.production"
makemigrations = "python manage.py makemigrations --settings=config.settings.production"
makemigrations = "python manage.py makemigrations --settings=config.settings.production {args}"

# Test environment
[tool.hatch.envs.test]
Expand Down

0 comments on commit c15af40

Please sign in to comment.