Suppression de Chant.numero
This commit is contained in:
		
							parent
							
								
									87ca842293
								
							
						
					
					
						commit
						daca903aba
					
				
					 7 changed files with 25 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -27,10 +27,10 @@ class MembreAdmin(admin.ModelAdmin):
 | 
			
		|||
 | 
			
		||||
@admin.register(Chant)
 | 
			
		||||
class ChantAdmin(admin.ModelAdmin):
 | 
			
		||||
    list_display = ["numero", "titre", "particularite", "statut"]
 | 
			
		||||
    list_display = ["titre", "particularite", "statut"]
 | 
			
		||||
    list_filter = ["statut"]
 | 
			
		||||
    search_fields = ["titre"]
 | 
			
		||||
    ordering = ["numero"]
 | 
			
		||||
    ordering = ["titre"]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@admin.register(User)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,7 +79,7 @@ class ChantDocForm(BootstrapMixin, forms.ModelForm):
 | 
			
		|||
class ChantEditForm(BootstrapMixin, forms.ModelForm):
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Chant
 | 
			
		||||
        fields = ["numero", "titre", "particularite"]
 | 
			
		||||
        fields = ["titre", "particularite"]
 | 
			
		||||
 | 
			
		||||
    def __init__(self, **kwargs):
 | 
			
		||||
        super().__init__(**kwargs)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										19
									
								
								beesgospel/migrations/0009_remove_numero.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								beesgospel/migrations/0009_remove_numero.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,19 @@
 | 
			
		|||
from django.db import migrations
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('beesgospel', '0008_chantdoc_lien'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.RemoveConstraint(
 | 
			
		||||
            model_name='chant',
 | 
			
		||||
            name='numero_unique',
 | 
			
		||||
        ),
 | 
			
		||||
        migrations.RemoveField(
 | 
			
		||||
            model_name='chant',
 | 
			
		||||
            name='numero',
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
| 
						 | 
				
			
			@ -106,18 +106,12 @@ class Chant(models.Model):
 | 
			
		|||
        PREP = "prep", "En préparation"
 | 
			
		||||
        INACTIF = "inactif", "Inactif"
 | 
			
		||||
 | 
			
		||||
    numero = models.PositiveSmallIntegerField("Numéro")
 | 
			
		||||
    titre = models.CharField("Titre", max_length=100)
 | 
			
		||||
    particularite = models.CharField("Particularité", max_length=100, blank=True)
 | 
			
		||||
    statut = models.CharField("Statut", max_length=10, choices=StatutChoices, default="actif")
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        constraints = [
 | 
			
		||||
            models.UniqueConstraint("numero", name="numero_unique"),
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return f"{self.numero}. {self.titre}"
 | 
			
		||||
        return self.titre
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ChantDoc(models.Model):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -126,5 +126,4 @@ tr.editable:hover .edit-button, tr.editable:hover .delete-button { display: inli
 | 
			
		|||
  text-decoration: none;
 | 
			
		||||
  height: 100%;
 | 
			
		||||
}
 | 
			
		||||
table.table-chants th.numero { width: 3em; }
 | 
			
		||||
table.table-chants th.boutons { width: 3em; }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -134,7 +134,7 @@ class ListeChantsView(LoginRequiredMixin, ListView):
 | 
			
		|||
    template_name = "membres/liste_chants.html"
 | 
			
		||||
 | 
			
		||||
    def get_queryset(self):
 | 
			
		||||
        return super().get_queryset().prefetch_related("chantdoc_set").order_by("numero")
 | 
			
		||||
        return super().get_queryset().prefetch_related("chantdoc_set").order_by("titre")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ChantAddView(PermissionRequiredMixin, CreateView):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,11 +4,10 @@
 | 
			
		|||
{% block content %}
 | 
			
		||||
    <h2>Liste des chants</h2>
 | 
			
		||||
    <table class="table table-striped table-bordered table-responsive table-chants">
 | 
			
		||||
        <tr><th scope="col" class="numero">N°</th><th scope="col">Titre</th><th></th><th></th>
 | 
			
		||||
        <tr><th scope="col">Titre</th><th></th><th></th>
 | 
			
		||||
            {% if perms.beesgospel.change_chant %}<th scope="col" class="boutons"></th>{% endif %}</tr>
 | 
			
		||||
    {% for chant in object_list %}
 | 
			
		||||
        <tr class="editable">
 | 
			
		||||
            <td>{{ chant.numero }}</td>
 | 
			
		||||
            <td>{{ chant.titre }}</td>
 | 
			
		||||
            <td>{% for doc in chant.chantdoc_set.all %}
 | 
			
		||||
                {% if doc.fichier %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue