Giant refactor
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,6 +1,5 @@ | |||||||
|  |  | ||||||
| /OACPL.iml | /OACPL.iml | ||||||
| /.idea/ | /.idea/ | ||||||
| /*/migrations/ | /*/migrations | ||||||
| /OACPL/settings.py | /OACPL/settings.py | ||||||
| /db.sqlite3 | /db.sqlite3 | ||||||
|   | |||||||
| @@ -1,12 +1,12 @@ | |||||||
| from django.contrib import admin | from django.contrib import admin | ||||||
|  |  | ||||||
| from case_law.models import Decision, Subtitle | from case_law.models import Case, Heading | ||||||
|  |  | ||||||
| admin.site.register(Subtitle) | admin.site.register(Heading) | ||||||
|  |  | ||||||
|  |  | ||||||
| @admin.register(Decision) | @admin.register(Case) | ||||||
| class DecisionAdmin(admin.ModelAdmin): | class DecisionAdmin(admin.ModelAdmin): | ||||||
|     fields = ['synopsis', 'headers', 'date', 'pdf'] |     fields = ['synopsis', 'headings', 'published', 'pdf'] | ||||||
|     filter_horizontal = ['headers'] |     filter_horizontal = ['headings'] | ||||||
|     list_display = ['synopsis', 'date'] |     list_display = ['synopsis', 'published'] | ||||||
|   | |||||||
							
								
								
									
										0
									
								
								case_law/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								case_law/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -1,22 +1,22 @@ | |||||||
| from django.db import models | from django.db import models | ||||||
|  |  | ||||||
|  |  | ||||||
| class Subtitle(models.Model): | class Heading(models.Model): | ||||||
|     name = models.CharField(max_length=100) |     name = models.CharField(max_length=100) | ||||||
|  |  | ||||||
|     def __str__(self): |     def __str__(self): | ||||||
|         return self.name |         return self.name | ||||||
|  |  | ||||||
|  |  | ||||||
| class Decision(models.Model): | class Case(models.Model): | ||||||
|  |  | ||||||
|     class Meta(object): |     class Meta(object): | ||||||
|         permissions = ( |         permissions = ( | ||||||
|             ('view_pdf', 'Can view PDF'), |             ('view_pdf', 'Can view PDF'), | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|     date = models.DateField() |     published = models.DateField() | ||||||
|     headers = models.ManyToManyField(Subtitle) |     headings = models.ManyToManyField(Heading) | ||||||
|     pdf = models.FileField(upload_to='secure') |     pdf = models.FileField(upload_to='secure') | ||||||
|     synopsis = models.TextField() |     synopsis = models.TextField() | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,10 +14,10 @@ | |||||||
|     <div id="search-filters" class="container-fluid bg-dark-primary text-white collapse"> |     <div id="search-filters" class="container-fluid bg-dark-primary text-white collapse"> | ||||||
|         <div class="container"> |         <div class="container"> | ||||||
|             <div class="row py-3"> |             <div class="row py-3"> | ||||||
|                 {% for header in allHeaders %} |                 {% for heading in allHeadings %} | ||||||
|                     <div class="col-xs-12 col-sm-6 col-md-4"> |                     <div class="col-xs-12 col-sm-6 col-md-4"> | ||||||
|                         <input id="input-{{ header.id }}" class="curs-pointer filters" name="filter" type="checkbox" value="{{ header }}"> |                         <input id="input-{{ heading.id }}" class="curs-pointer filters" name="filter" type="checkbox" value="{{ heading }}"> | ||||||
|                         <label for="input-{{ header.id }}" class="curs-pointer">{{ header }}</label> |                         <label for="input-{{ heading.id }}" class="curs-pointer">{{ heading }}</label> | ||||||
|                     </div> |                     </div> | ||||||
|                 {% endfor %} |                 {% endfor %} | ||||||
|                 <div class="col-12"> |                 <div class="col-12"> | ||||||
| @@ -53,24 +53,24 @@ | |||||||
|             {% endif %} |             {% endif %} | ||||||
|             <div class="row p-3"> |             <div class="row p-3"> | ||||||
|                 <div class="col-lg-12 ml-auto text-dark-primary"> |                 <div class="col-lg-12 ml-auto text-dark-primary"> | ||||||
|                     {% if headersCount > 1 and decisionsCount > 1 and not filter %} |                     {% if headingCount > 1 and headingCount > 1 and not filter %} | ||||||
|                         <h4>Headings</h4> |                         <h4>Headings</h4> | ||||||
|                         <hr> |                         <hr> | ||||||
|                         {% for header in headers %} |                         {% for heading in headings %} | ||||||
|                             <div> |                             <div> | ||||||
|                                 <a href="{% url 'browser' %}?path={% if url %}{{ url }}/{% endif %}{{ header }}"> |                                 <a href="{% url 'browser' %}?path={% if url %}{{ url }}/{% endif %}{{ heading }}"> | ||||||
|                                     <h4 class="d-inline-block"><i class="fa fa-folder-open-o"></i> {{ header }}</h4> |                                     <h4 class="d-inline-block"><i class="fa fa-folder-open-o"></i> {{ heading }}</h4> | ||||||
|                                 </a> |                                 </a> | ||||||
|                             </div> |                             </div> | ||||||
|                         {% endfor %} |                         {% endfor %} | ||||||
|                         <br> |                         <br> | ||||||
|                     {% endif %} |                     {% endif %} | ||||||
|                     <h4>Decisions</h4> |                     <h4>Cases</h4> | ||||||
|                     <hr> |                     <hr> | ||||||
|                     {% for decision in decisions %} |                     {% for case in cases %} | ||||||
|                         <div> |                         <div> | ||||||
|                             <a href="{% url 'case' decision.id %}"> |                             <a href="{% url 'case' case.id %}"> | ||||||
|                                 <h4 class="d-inline-block"><i class="fa fa-file-text-o"></i> {{ decision.synopsis }}</h4> |                                 <h4 class="d-inline-block"><i class="fa fa-file-text-o"></i> {{ case.synopsis }}</h4> | ||||||
|                             </a> |                             </a> | ||||||
|                         </div> |                         </div> | ||||||
|                     {% endfor %} |                     {% endfor %} | ||||||
| @@ -80,7 +80,7 @@ | |||||||
|     </div> |     </div> | ||||||
|     <div class="container-fluid bg-dark-primary p-2"> |     <div class="container-fluid bg-dark-primary p-2"> | ||||||
|         <div class="container text-white"> |         <div class="container text-white"> | ||||||
|             {% if headersCount %}{{ headersCount }} Headers, {% endif %}{{ decisionsCount }} Decision{% if decisionsCount > 1 %}s{% endif %} |             {% if headingCount %}{{ headingCount }} Headings, {% endif %}{{ caseCount }} Case{% if caseCount > 1 %}s{% endif %} | ||||||
|         </div> |         </div> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										19
									
								
								case_law/templates/case.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								case_law/templates/case.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | {% extends 'base.html' %} | ||||||
|  | {% load static %} | ||||||
|  |  | ||||||
|  | {% block body %} | ||||||
|  |     <div class="container-fluid bg-light-blue py-3"> | ||||||
|  |         <div class="container"> | ||||||
|  |             <h3 class="text-dark-primary">Synopsis</h3> | ||||||
|  |             {% for heading in headings %} | ||||||
|  |                 <span class="badge badge-primary">{{ heading }}</span> | ||||||
|  |             {% endfor %} | ||||||
|  |             <p>{{ case.synopsis | linebreaks }}</p> | ||||||
|  |             <h6 class="text-muted">Published: {{ case.published }}</h6> | ||||||
|  |             {% if perms.case_law.view_pdf %} | ||||||
|  |                 <a href="/media/{{ case.pdf }}">View PDF</a> | ||||||
|  |                 <br> | ||||||
|  |             {% endif %} | ||||||
|  |         </div> | ||||||
|  |     </div> | ||||||
|  | {% endblock %} | ||||||
| @@ -1,19 +0,0 @@ | |||||||
| {% extends 'base.html' %} |  | ||||||
| {% load static %} |  | ||||||
|  |  | ||||||
| {% block head %} |  | ||||||
|  |  | ||||||
| {% endblock %} |  | ||||||
|  |  | ||||||
| {% block body %} |  | ||||||
|     <div class="container-fluid bg-light-blue py-3"> |  | ||||||
|         <div class="container"> |  | ||||||
|             <h1>Synopsis</h1> |  | ||||||
|             <h6 class="text-muted">Date: {{ decision.date }}</h6> |  | ||||||
|             <p>{{ decision.synopsis | linebreaks }}</p> |  | ||||||
|             {% if perms.case_law.view_pdf %} |  | ||||||
|                 <a href="/media/{{ decision.pdf }}">View PDF</a> |  | ||||||
|             {% endif %} |  | ||||||
|         </div> |  | ||||||
|     </div> |  | ||||||
| {% endblock %} |  | ||||||
| @@ -1,42 +1,42 @@ | |||||||
| from django.shortcuts import render | from django.shortcuts import render | ||||||
|  |  | ||||||
| from .models import Decision, Subtitle | from .models import Case, Heading | ||||||
|  |  | ||||||
|  |  | ||||||
| def browser(request): | def browser(request): | ||||||
|     headers = {} |     headings = {} | ||||||
|     path = request.GET.get('path') |     path = request.GET.get('path') | ||||||
|     filter = request.GET.get('filter') |     filter = request.GET.get('filter') | ||||||
|     decisions = Decision.objects.all() |     cases = Case.objects.all() | ||||||
|     if filter: |     if filter: | ||||||
|         filter = filter.split('/') |         filter = filter.split('/') | ||||||
|         print(filter) |         print(filter) | ||||||
|         ids = Subtitle.objects.filter(name__in=filter).values_list('id') |         ids = Heading.objects.filter(name__in=filter).values_list('id') | ||||||
|         for id in ids: |         for id in ids: | ||||||
|             decisions = decisions.filter(headers__in=id) |             cases = cases.filter(headings__in=id) | ||||||
|     elif path: |     elif path: | ||||||
|         path = path.split('/') |         path = path.split('/') | ||||||
|         ids = Subtitle.objects.filter(name__in=path).values_list('id') |         ids = Heading.objects.filter(name__in=path).values_list('id') | ||||||
|         for id in ids: |         for id in ids: | ||||||
|             decisions = decisions.filter(headers__in=id) |             cases = cases.filter(headings__in=id) | ||||||
|  |  | ||||||
|     headers = set() |     headings = set() | ||||||
|     for decision in decisions: |     for decision in cases: | ||||||
|         headers = headers.union(decision.headers.all().values_list('name', flat=True)) |         headings = headings.union(decision.headings.all().values_list('name', flat=True)) | ||||||
|     if path: headers = headers.difference(path) |     if path: headings = headings.difference(path) | ||||||
|  |  | ||||||
|     return render(request, 'browser.html', { |     return render(request, 'browser.html', { | ||||||
|         'allHeaders': Subtitle.objects.all().order_by('name'), |         'allHeadings': Heading.objects.all().order_by('name'), | ||||||
|         'decisions': decisions.order_by('synopsis'), |         'cases': cases.order_by('synopsis'), | ||||||
|         'decisionsCount': len(decisions), |         'caseCount': len(cases), | ||||||
|         'filter': filter, |         'filter': filter, | ||||||
|         'headers': sorted(headers), |         'headings': sorted(headings), | ||||||
|         'headersCount': len(headers), |         'headingCount': len(headings), | ||||||
|         'url': request.GET.get('path'), |         'url': request.GET.get('path'), | ||||||
|         'urls': path |         'urls': path | ||||||
|     }) |     }) | ||||||
|  |  | ||||||
|  |  | ||||||
| def case(request, id): | def case(request, id): | ||||||
|     decision = Decision.objects.get(id=id) |     case = Case.objects.get(id=id) | ||||||
|     return render(request, 'decision.html', {'decision': decision}) |     return render(request, 'case.html', {'case': case, 'headings': case.headings.all()}) | ||||||
|   | |||||||
							
								
								
									
										0
									
								
								charter_members/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								charter_members/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								expert_witnesses/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								expert_witnesses/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -1,6 +1,6 @@ | |||||||
| from django.db import models | from django.db import models | ||||||
|  |  | ||||||
| from case_law.models import Decision | from case_law.models import Case | ||||||
|  |  | ||||||
|  |  | ||||||
| class AreaOfExpertise(models.Model): | class AreaOfExpertise(models.Model): | ||||||
| @@ -15,7 +15,7 @@ class AreaOfExpertise(models.Model): | |||||||
|  |  | ||||||
|  |  | ||||||
| class Expert(models.Model): | class Expert(models.Model): | ||||||
|     cases = models.ManyToManyField(Decision, null=True, blank=True) |     cases = models.ManyToManyField(Case, null=True, blank=True) | ||||||
|     expertise = models.ManyToManyField(AreaOfExpertise) |     expertise = models.ManyToManyField(AreaOfExpertise) | ||||||
|     institute = models.CharField(max_length=255, null=True, blank=True) |     institute = models.CharField(max_length=255, null=True, blank=True) | ||||||
|     name = models.CharField(max_length=255) |     name = models.CharField(max_length=255) | ||||||
|   | |||||||
							
								
								
									
										0
									
								
								forum/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								forum/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								main/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								main/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								newsletters/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								newsletters/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
		Reference in New Issue
	
	Block a user