Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contacts abdoulaye toure #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions noyau/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from django.contrib import admin
from .models import Contacts

@admin.register(Contacts)
class Contacts(admin.ModelAdmin):

list_display=('tel_portable','tel_domicile','tel_bureau','email')


# Register your models here.
10 changes: 10 additions & 0 deletions noyau/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django import forms
class ConnectForm(forms.Form):
login = forms.CharField(max_length=30)
m_pass = forms.CharField(label="Mot de passe", widget=forms.PasswordInput)

from .models import *
class CreerContactsForm(forms.ModelForm):
class Meta:
model = Contacts
fields = '__all__'
13 changes: 13 additions & 0 deletions noyau/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
from django.db import models


class Contacts(models.Model):
tel_portable = models.CharField(max_length=50)
tel_domicile = models.CharField(max_length=50)
tel_bureau = models.CharField(max_length=50)
email = models.CharField(max_length=50)

class Meta:
verbose_name = "contacts"
def __str__(self):
return "({0}, {1}, {2},{3},{})".format(self.id,self.tel_portable, self.tel_domicile,self.tel_bureau,self.email)


# Create your models here.
31 changes: 31 additions & 0 deletions noyau/templates/noyau/ajouterContacts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% extends "base.html" %}

{% block title %}
AjouterContact
{% endblock %}

{% block content %}
{% include "noyau/nav.html" %}
<form>

<div class="form-group">
<label for="TEL_PORTABLE">TEL_PORTABLE</label>
<input type="tel" class="form-control" id="TEL_PORTABLE" placeholder="TEL_PORTABLE">
</div>
<div class="form-group">
<label for="TEL_DOMICILE">TEL_DOMICILE</label>
<input type="tel" class="form-control" id="TEL_DOMICILE" placeholder="TEL_DOMICILE">
</div>
<div class="form-group">
<label for="TEL_BUREAU">TEL_BUREAU</label>
<input type="tel" class="form-control" id="TEL_BUREAU" placeholder="TEL_BUREAU">
</div>
<div class="form-group">
<label for="EMAIL">EMAIL</label>
<input type="text" class="form-control" id="EMAIL" placeholder="EMAIL">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
{% include "noyau/footer.html" %}

{% endblock %}
69 changes: 69 additions & 0 deletions noyau/templates/noyau/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<footer class="bg-light text-center text-white">
<!-- Grid container -->
<div class="container p-4 pb-0">
<!-- Section: Social media -->
<section class="mb-4">
<!-- Facebook -->
<a
class="btn btn-primary btn-floating m-1"
style="background-color: #3b5998;"
href="#!"
role="button"
><i class="fab fa-facebook-f"></i
></a>

<!-- Twitter -->
<a
class="btn btn-primary btn-floating m-1"
style="background-color: #55acee;"
href="#!"
role="button"
><i class="fab fa-twitter"></i
></a>

<!-- Google -->
<a
class="btn btn-primary btn-floating m-1"
style="background-color: #dd4b39;"
href="#!"
role="button"
><i class="fab fa-google"></i
></a>

<!-- Instagram -->
<a
class="btn btn-primary btn-floating m-1"
style="background-color: #ac2bac;"
href="#!"
role="button"
><i class="fab fa-instagram"></i
></a>

<!-- Linkedin -->
<a
class="btn btn-primary btn-floating m-1"
style="background-color: #0082ca;"
href="#!"
role="button"
><i class="fab fa-linkedin-in"></i
></a>
<!-- Github -->
<a
class="btn btn-primary btn-floating m-1"
style="background-color: #333333;"
href="#!"
role="button"
><i class="fab fa-github"></i
></a>
</section>
<!-- Section: Social media -->
</div>
<!-- Grid container -->

<!-- Copyright -->
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2);">
© 2020 Copyright:
<a class="text-white" href="https://mdbootstrap.com/">MDBootstrap.com</a>
</div>
<!-- Copyright -->
</footer>
58 changes: 58 additions & 0 deletions noyau/templates/noyau/listerContacts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% extends "base.html" %}
{% block title %}
Liste des contacts
{% endblock %}
{% block content %}

{% include "noyau/nav.html" %}
<h1> Liste des contacts </h1>

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.21/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.21/datatables.min.js"></script>
<script>$(document).ready( function (){<font></font>
$('myTable').DataTable();<font></font>
} );<font></font>
</script>

<div class="table-responsive" style="border: solid;">
<table id="bootstrapdatatable" class="table table-striped table-bordered" width="100%">
<thead>
<tr>
<th><input type="checkbox" id="checkall" /></th>
<th>ID</th>
<th scope="col">TEL_PORTABLE</th>
<th scope="col">TEL_DOMICILE</th>
<th scope="col">TEL_BUREAU</th>
<th scope="col">EMAIL</th>

</tr>
</thead>
<tbody>
{% for contacts in contacts %}

<tr>
<td style="text-align: center;"><input type="checkbox" class="checkthis" /></td>
<td style="text-align: center;">{{ contacts.id }}</td>
<td style="text-align: center;">{{contacts.tel_portable}}</td>
<td style="text-align: center;">{{contacts.tel_domicile}}</td>
<td style="text-align: center;">{{contacts.tel_bureau}}</td>
<td style="text-align: center;">{{contacts.email}}</td>

<td ><span><a href="{% url 'ajouterContacts' %}"class="btn btn-primary">Modifier</a></span></td>
<td ><span><a href="{% url 'ajouterContacts' %}"class="btn btn-primary">Supprimer</a></span></td>
</tr>



{% endfor %}
</tbody>
</table>
</br>


</div>

Cliquez pour ajouter un contact <span><a href="{% url 'ajouterContacts' %}"class="btn btn-primary">Ajouter</a></span>

{% include "noyau/footer.html" %}
{% endblock content %}
25 changes: 25 additions & 0 deletions noyau/templates/noyau/nav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
11 changes: 11 additions & 0 deletions noyau/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

from django.conf import settings
from django.urls import path
from noyau import views
from django.contrib import admin

urlpatterns = [
path('admin/', admin.site.urls),
path('',views.listerContacts,name="listerContacts"),
path("addContacts/", views.ajouterContacts, name="ajouterContacts"),
]
26 changes: 24 additions & 2 deletions noyau/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
from django.shortcuts import render
from django.shortcuts import render,redirect
from .models import *
from django.http import HttpResponse
from django.db import models
from .forms import CreerContactsForm

# Create your views here.

def listerContacts(request):
from django.http import Http404
contacts = Contacts.objects.all()
#auteurs = Auteur.objects.all()

context = {'contacts': contacts}

return render(request, "noyau/listerContacts.html", context)

def ajouterContacts(request):
from django.http import Http404
if request.method == 'POST':
form = CreerContactsForm()
form= CreerContactsForm(request.POST)
if form.is_valid():
form.save()

return render(request, 'noyau/ajouterContacts.html')
4 changes: 2 additions & 2 deletions ogii/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'noyau'
'noyau',
]

MIDDLEWARE = [
Expand All @@ -55,7 +55,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS':[os.path.join(BASE_DIR,"templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand Down
3 changes: 2 additions & 1 deletion ogii/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path
from django.urls import path,include

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('noyau.urls'))
]

if settings.DEBUG:
Expand Down
Loading