Skip to content

Commit

Permalink
Merge pull request #99 from Varsha010101/main
Browse files Browse the repository at this point in the history
BUG FIXED IN THE CONTACT ME PAGE
  • Loading branch information
SiddharthBahuguna authored Jun 1, 2024
2 parents 098f788 + d5e2455 commit 1055407
Show file tree
Hide file tree
Showing 34 changed files with 95 additions and 58 deletions.
1 change: 1 addition & 0 deletions newsaggregator/NEWS-AGGREGATOR-PROJECT
Submodule NEWS-AGGREGATOR-PROJECT added at d942ce
Binary file modified newsaggregator/core/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/core/__pycache__/admin.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/core/__pycache__/apps.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/core/__pycache__/forms.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/core/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/core/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/core/__pycache__/views.cpython-312.pyc
Binary file not shown.
7 changes: 4 additions & 3 deletions newsaggregator/core/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from core.models import Headline,Bookmark

from core.models import Headline,Bookmark,Contact
admin.site.register(Headline)
admin.site.register(Bookmark)
admin.site.register(Bookmark)
admin.site.register(Contact)
# Register your models here.
8 changes: 0 additions & 8 deletions newsaggregator/core/forms.py

This file was deleted.

24 changes: 24 additions & 0 deletions newsaggregator/core/migrations/0002_contact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.0.6 on 2024-05-30 09:47

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Contact',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('email', models.EmailField(max_length=254, validators=[django.core.validators.EmailValidator()])),
('phone', models.CharField(blank=True, max_length=20)),
('message', models.TextField(blank=True, max_length=20)),
],
),
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions newsaggregator/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@

from django.dispatch import receiver

from django.core.validators import EmailValidator

class Contact(models.Model):
name = models.CharField(max_length=255)
email = models.EmailField(validators=[EmailValidator()])
phone = models.IntegerField(max_length=10, blank=True)
message= models.TextField(max_length=20, blank=True)


def __str__(self):
return self.name + " - " + self.email




class Headline(models.Model):
title = models.CharField(max_length=200)#title char(200)
Expand Down
8 changes: 4 additions & 4 deletions newsaggregator/core/urls.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from django.urls import path
from core import views
from .views import submit_contact

app_name='core'

urlpatterns=[
path('',views.news_list,name='index'),
path('about/',views.about,name='about'),
path('contact/',views.contact,name='contact'),
path('contact.html/',views.submit_contact,name='contact'),

path('advertise/',views.advertise,name='advertise'),
path('privacy/',views.privacy,name='privacy'),
path('scrape/<str:name>', views.scrape, name="scrape"),



# bookmarking
# bookmarking
path('bookmarks/', views.view_bookmarks, name='view_bookmarks'),

path('remove_bookmark/<int:headline_id>/', views.remove_bookmark, name='remove_bookmark'),
Expand Down
46 changes: 17 additions & 29 deletions newsaggregator/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from core.models import Headline

from datetime import datetime
from core.forms import ContactForm

from core.models import Contact
from django.template.loader import render_to_string
from django.core.mail import send_mail

Expand Down Expand Up @@ -134,35 +135,22 @@ def about(request):
return render(request, "core/about.html", context)

@login_required(login_url='userauths:sign-in')
def contact(request):
today_date = datetime.now().strftime('%Y-%m-%d')
if request.method == "POST":
form = ContactForm(request.POST)

if form.is_valid():
name = form.cleaned_data['name']
email = form.cleaned_data['email']
phone = form.cleaned_data['phone']
content = form.cleaned_data['content']

html = render_to_string('components/email.html', {
'name': name,
'email': email,
'phone': phone,
'content': content,
})

send_mail("The contact form subject", 'this is the message', email, ['[email protected]'], html_message=html)
messages.success(request, 'Form submitted successfully!')
return redirect("core:index")
else:
form = ContactForm()
def submit_contact(request):
if request.method == 'POST':
name = request.POST.get('name')
email = request.POST.get('email')
phone= request.POST.get('phone')
message = request.POST.get('message')
contact=Contact()
contact.name=name
contact.email=email
contact.phone=phone
contact.message=message
contact.save()
messages.success(request,"Thanks for contacting us")
return redirect("/contact.html")
return render(request, "core/contact.html")

context={
'today_date': today_date,
'form': form,
}
return render(request,"core/contact.html",context)

@login_required(login_url='userauths:sign-in')
def advertise(request):
Expand Down
Binary file modified newsaggregator/db.sqlite3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified newsaggregator/newsaggregator/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/newsaggregator/__pycache__/wsgi.cpython-312.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions newsaggregator/newsaggregator/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'jazzmin',
'django.contrib.admin',
'django.contrib.auth',

'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
Expand Down
1 change: 1 addition & 0 deletions newsaggregator/newsaggregator/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
path('admin/', admin.site.urls),
path('user/',include('userauths.urls')),
path('',include('core.urls')),

]
43 changes: 29 additions & 14 deletions newsaggregator/templates/core/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

<div class="col-md-12">
<br>
{%for msg in messages%}
<div class="alert alert-success d-flex align-items-center" role="alert" style="height:50px">
<svg class="bi flex-shrink-0 me-2" role="img" aria-label="Success:"><use xlink:href="#check-circle-fill"/></svg>
<div>{{msg}}</div></div>

{%endfor%}
<h2 class="h2">Contact Me</h2>

<div class="blog-card-group">
Expand All @@ -21,33 +27,42 @@ <h2 class="h2">Contact Me</h2>
{% csrf_token %}
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{form.name}}
<div class="name">
<label for="name"></label>
<input type="text" placeholder="Your name is" name="name" id="name_input" required>
</div>
<div class="email">
<label for="email"></label>
<input type="email" placeholder="Your e-mail is" name="email" id="email_input" required>
</div>
<div class="phone">
<label for="phone number"></label>
<input type="text" placeholder="Your Phone Number" name="phone" id="phone_input" required>
</div>
<div class="form-group">
{{form.email}}
</div>
<div class="form-group">
{{form.phone}}
</div>

</div>
<div class="col-md-6">
<div class="form-group">
{{form.content}}
<div class="col-md-6">
<div class="message">
<label for="message"></label>
<textarea name="message" placeholder="I'd like to chat about" id="message_input" cols="30" rows="5" required></textarea>
</div>
</div>
</div>

<div class="form-group">
</br>


<button class="btn btn-secondary" type="submit"
style="width: min-content;padding: .2em;border: 1px solid #a0aec0;border-bottom: 2px solid #a0aec0;">Submit</button>
</div>

</div>
</div>
</form>
</div>


</div>
</div>




Expand Down
Binary file modified newsaggregator/userauths/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/userauths/__pycache__/admin.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/userauths/__pycache__/apps.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/userauths/__pycache__/forms.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/userauths/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/userauths/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file modified newsaggregator/userauths/__pycache__/views.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 1055407

Please sign in to comment.