Revert migration that create groups

       It is already done in a command named "init_groups"
parent 4dd89717
......@@ -18,6 +18,6 @@ class TagMultipleChoiceField(forms.ModelMultipleChoiceField):
class SignupForm(forms.Form):
def signup(self, request, user):
group = Group.objects.get(name='Padawan')
group = Group.objects.get(name='padawan')
user.groups.add(group)
user.save()
from django.db import migrations
from django.contrib.auth.models import Group
def add_groups(apps, schema_editor):
groups = ['Jedi', 'Padawan', 'Droid']
groups = ['Jedi', 'Padawan', 'Droid']
def add_groups(apps, schema_editor):
for i in groups:
group = Group(name=i)
group.save()
def remove_groups(apps, schema_editor):
Group.objects.all().delete()
for i in groups:
Group.objects.filter(name=i).delete()
class Migration(migrations.Migration):
......
from django.db import migrations
from django.contrib.auth.models import Group, User
def add_groups(apps, schema_editor):
users = User.objects.all()
padawanGroup = Group.objects.get(name='Padawan')
def remove_groups(apps, schema_editor):
groups = ['Jedi', 'Padawan', 'Droid']
for i in groups:
Group.objects.filter(name=i).delete()
for user in users:
user.groups.add(padawanGroup)
user.save()
class Migration(migrations.Migration):
......@@ -16,5 +15,5 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(add_groups),
migrations.RunPython(remove_groups),
]
......@@ -58,7 +58,7 @@
<li class="nav-item">
<a class="nav-link">
Vous êtes {{user.groups.all.0.name}}
{% if user.groups.all.0.name == "Padawan" %}
{% if user.groups.all.0.name == "padawan" %}
<img class="inline-image ml-2" role="img" src="{% static 'img/padawan.svg' %}" />
{% elif user.groups.all.0.name == "Jedi" %}
<img class="inline-image ml-2" role="img" src="{% static 'img/jedi.svg' %}" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment