-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from swe574-spring23/SpaceModelUpdates
DEV | My Own Spaces and Space Policy Update
- Loading branch information
Showing
13 changed files
with
255 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.1.1 on 2023-03-13 20:00 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('posts', '0004_auto_20230313_2153'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='comment', | ||
name='id', | ||
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), | ||
), | ||
migrations.AlterField( | ||
model_name='post', | ||
name='id', | ||
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 3.1.1 on 2023-03-13 20:00 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('spaces', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='space', | ||
name='is_all_members_post_allowed', | ||
), | ||
migrations.RemoveField( | ||
model_name='space', | ||
name='is_only_moderators_post_allowed', | ||
), | ||
migrations.AddField( | ||
model_name='space', | ||
name='granted_members', | ||
field=models.ManyToManyField(blank=True, related_name='granted_spaces', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='space', | ||
name='posting_permission', | ||
field=models.CharField(choices=[('all', 'Any member can post'), ('granted', 'Only granted members can post'), ('moderators', 'Only moderators can post')], default='all', max_length=47), | ||
), | ||
migrations.AlterField( | ||
model_name='space', | ||
name='id', | ||
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends 'base.html' %} | ||
{% block content %} | ||
<h1>My Spaces</h1> | ||
{% if spaces %} | ||
<ul> | ||
{% for space in spaces %} | ||
<li><a href="{% url 'space_detail' pk=space.pk %}">{{ space.name }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% else %} | ||
<p>You don't have any spaces yet.</p> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<h1>Spaces</h1> | ||
<ul> | ||
{% for space in spaces %} | ||
<li> | ||
<h2>{{ space.name }}</h2> | ||
<p>{{ space.description }}</p> | ||
<p>Owner: {{ space.owner.username }}</p> | ||
<p>Members: {{ space.members.count }}</p> | ||
<p>Moderators: {{ space.moderators.count }}</p> | ||
<p>Posts: {{ space.posts.count }}</p> | ||
<a href="{% url 'space_detail' space.id %}">View Space</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
<h1>Spaces</h1> | ||
<div class="row row-cols-1 row-cols-md-3 g-4"> | ||
{% for space in spaces %} | ||
<div class="col"> | ||
<div class="card h-100"> | ||
<div class="card-body"> | ||
<h2 class="card-title">{{ space.name }}</h2> | ||
<p class="card-text">{{ space.description }}</p> | ||
<ul class="list-group list-group-flush"> | ||
<li class="list-group-item">Owner: {{ space.owner.username }}</li> | ||
<li class="list-group-item">Members: {{ space.members.count }}</li> | ||
<li class="list-group-item">Moderators: {{ space.moderators.count }}</li> | ||
<li class="list-group-item">Posts: {{ space.posts.count }}</li> | ||
</ul> | ||
<a href="{% url 'space_detail' space.id %}" class="btn btn-primary mt-3">View Space</a> | ||
{% if user.is_authenticated and user == space.owner %} | ||
<a href="{% url 'space_policies' space.id %}" class="btn btn-secondary mt-3">Define Policies</a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<div style="border: 1px solid black; padding: 10px;"> | ||
<h1>Space Policies</h1> | ||
<form method="post"> | ||
{% csrf_token %} | ||
<div class="mb-3"> | ||
<label for="{{ form.posting_permission.id_for_label }}" class="form-label">Posting Permission:</label> | ||
<div class="form-check form-check-inline"> | ||
{{ form.posting_permission }} | ||
</div> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Save</button> | ||
</form> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from django.urls import path | ||
|
||
from spaces.views import create_space, space_detail, space_list | ||
from spaces.views import create_space, space_detail, space_list, my_spaces_list, space_policies | ||
|
||
urlpatterns = [ | ||
path("spaces/", space_list, name="space_list"), | ||
path("spaces/new/", create_space, name="create_space"), | ||
path("spaces/<int:pk>/", space_detail, name="space_detail"), | ||
path("spaces/myspaces/", my_spaces_list, name="my_spaces_list"), | ||
path("spaces/<int:pk>/policies/", space_policies, name="space_policies"), | ||
|
||
] |
Oops, something went wrong.