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

ADD image #49

Closed
wants to merge 5 commits into from
Closed
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
78 changes: 78 additions & 0 deletions .github/workflows/main_gestion-restau.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions

name: Build and deploy Python app to Azure Web App - Gestion-Restau

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate

- name: Install dependencies
run: pip install -r requirements.txt

# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Zip artifact for deployment
run: zip release.zip ./* -r

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v4
with:
name: python-app
path: |
release.zip
!venv/

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: python-app

- name: Unzip artifact for deployment
run: unzip release.zip


- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_126AB9A3CDD84879A8AC7CAAAAFE2AD4 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_16F36252B6D442A7BC681B96CCAC659E }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_CAD2C27026F34EE89714485FB175CE1F }}

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'Gestion-Restau'
slot-name: 'Production'

5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"main"
]
}
1 change: 1 addition & 0 deletions notifications.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

38 changes: 37 additions & 1 deletion templates/create_restaurant.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,44 @@ <h1>Add New Restaurant</h1>
<label for="description" class="form-label">Description</label>
<input type="text" class="form-control" id="description" name="description">
</div>
<input type="file" class="form-control" id="photo" name="photo">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="cancel" class="btn btn-primary">Cancel</button>
<button type="cancel" class="btn btn-secondary">Cancel</button>
</form>

<!-- Bouton pour envoyer un email via Logic App -->
<button id="sendEmailButton" class="btn btn-success mt-3">Envoyer un email</button>

<script>
document.getElementById('sendEmailButton').addEventListener('click', function () {
const url = "https://prod-52.northeurope.logic.azure.com:443/workflows/c6fb2a86af7e4edf94b4c0e1679293e9/triggers/When_a_HTTP_request_is_received/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2FWhen_a_HTTP_request_is_received%2Frun&sv=1.0&sig=ikT3oWZG8GAzeO4R3GH2hXduO4pSryVqsw_gRsz99L8";

const body = {
"to": "[email protected]",
"subject": "Nouveau Restaurant Ajouté",
"body": `Un nouveau restaurant a été ajouté :\n\nNom: ${document.getElementById('restaurant_name').value}\nAdresse: ${document.getElementById('street_address').value}\nDescription: ${document.getElementById('description').value}`
};

fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
.then(response => {
if (response.ok) {
alert('Email envoyé avec succès !');
} else {
alert('Erreur lors de l\'envoi de l\'email.');
}
})
.catch(error => {
console.error('Erreur:', error);
alert('Une erreur s\'est produite.');
});
});
</script>
{% endblock %}