diff --git a/newsaggregator/NEWS-AGGREGATOR-PROJECT b/newsaggregator/NEWS-AGGREGATOR-PROJECT new file mode 160000 index 0000000..d942ce1 --- /dev/null +++ b/newsaggregator/NEWS-AGGREGATOR-PROJECT @@ -0,0 +1 @@ +Subproject commit d942ce168190d26603742845aa4add8248b9e984 diff --git a/newsaggregator/core/__pycache__/__init__.cpython-312.pyc b/newsaggregator/core/__pycache__/__init__.cpython-312.pyc index 7a36f85..43cdd5e 100644 Binary files a/newsaggregator/core/__pycache__/__init__.cpython-312.pyc and b/newsaggregator/core/__pycache__/__init__.cpython-312.pyc differ diff --git a/newsaggregator/core/__pycache__/admin.cpython-312.pyc b/newsaggregator/core/__pycache__/admin.cpython-312.pyc index 41a2749..f0219b4 100644 Binary files a/newsaggregator/core/__pycache__/admin.cpython-312.pyc and b/newsaggregator/core/__pycache__/admin.cpython-312.pyc differ diff --git a/newsaggregator/core/__pycache__/apps.cpython-312.pyc b/newsaggregator/core/__pycache__/apps.cpython-312.pyc index 235f518..11a5c0b 100644 Binary files a/newsaggregator/core/__pycache__/apps.cpython-312.pyc and b/newsaggregator/core/__pycache__/apps.cpython-312.pyc differ diff --git a/newsaggregator/core/__pycache__/forms.cpython-312.pyc b/newsaggregator/core/__pycache__/forms.cpython-312.pyc index e750832..95526c2 100644 Binary files a/newsaggregator/core/__pycache__/forms.cpython-312.pyc and b/newsaggregator/core/__pycache__/forms.cpython-312.pyc differ diff --git a/newsaggregator/core/__pycache__/models.cpython-312.pyc b/newsaggregator/core/__pycache__/models.cpython-312.pyc index ecd4ad5..4db0e27 100644 Binary files a/newsaggregator/core/__pycache__/models.cpython-312.pyc and b/newsaggregator/core/__pycache__/models.cpython-312.pyc differ diff --git a/newsaggregator/core/__pycache__/urls.cpython-312.pyc b/newsaggregator/core/__pycache__/urls.cpython-312.pyc index 26a2df8..41102d5 100644 Binary files a/newsaggregator/core/__pycache__/urls.cpython-312.pyc and b/newsaggregator/core/__pycache__/urls.cpython-312.pyc differ diff --git a/newsaggregator/core/__pycache__/views.cpython-312.pyc b/newsaggregator/core/__pycache__/views.cpython-312.pyc index e5380c5..b2b9829 100644 Binary files a/newsaggregator/core/__pycache__/views.cpython-312.pyc and b/newsaggregator/core/__pycache__/views.cpython-312.pyc differ diff --git a/newsaggregator/core/admin.py b/newsaggregator/core/admin.py index 602462f..ebf32b9 100644 --- a/newsaggregator/core/admin.py +++ b/newsaggregator/core/admin.py @@ -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) \ No newline at end of file +admin.site.register(Bookmark) +admin.site.register(Contact) +# Register your models here. diff --git a/newsaggregator/core/forms.py b/newsaggregator/core/forms.py deleted file mode 100644 index e440570..0000000 --- a/newsaggregator/core/forms.py +++ /dev/null @@ -1,8 +0,0 @@ -from django import forms - - -class ContactForm(forms.Form): - name = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'placeholder': 'Your Name'})) - email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'Your Email'})) - phone = forms.IntegerField(widget=forms.NumberInput(attrs={'placeholder': 'Your Phone Number'})) - content = forms.CharField(widget=forms.Textarea(attrs={'placeholder': 'Your Message'})) diff --git a/newsaggregator/core/migrations/0002_contact.py b/newsaggregator/core/migrations/0002_contact.py new file mode 100644 index 0000000..6e9125a --- /dev/null +++ b/newsaggregator/core/migrations/0002_contact.py @@ -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)), + ], + ), + ] diff --git a/newsaggregator/core/migrations/__pycache__/0001_initial.cpython-312.pyc b/newsaggregator/core/migrations/__pycache__/0001_initial.cpython-312.pyc index 46497e1..1aba620 100644 Binary files a/newsaggregator/core/migrations/__pycache__/0001_initial.cpython-312.pyc and b/newsaggregator/core/migrations/__pycache__/0001_initial.cpython-312.pyc differ diff --git a/newsaggregator/core/migrations/__pycache__/0002_contact.cpython-312.pyc b/newsaggregator/core/migrations/__pycache__/0002_contact.cpython-312.pyc new file mode 100644 index 0000000..6ac02f4 Binary files /dev/null and b/newsaggregator/core/migrations/__pycache__/0002_contact.cpython-312.pyc differ diff --git a/newsaggregator/core/migrations/__pycache__/__init__.cpython-312.pyc b/newsaggregator/core/migrations/__pycache__/__init__.cpython-312.pyc index 28f40e2..02b0fbd 100644 Binary files a/newsaggregator/core/migrations/__pycache__/__init__.cpython-312.pyc and b/newsaggregator/core/migrations/__pycache__/__init__.cpython-312.pyc differ diff --git a/newsaggregator/core/models.py b/newsaggregator/core/models.py index f3b8750..cb577d1 100644 --- a/newsaggregator/core/models.py +++ b/newsaggregator/core/models.py @@ -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) diff --git a/newsaggregator/core/urls.py b/newsaggregator/core/urls.py index 7cf5f44..962cd06 100644 --- a/newsaggregator/core/urls.py +++ b/newsaggregator/core/urls.py @@ -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/', views.scrape, name="scrape"), - - - # bookmarking + # bookmarking path('bookmarks/', views.view_bookmarks, name='view_bookmarks'), path('remove_bookmark//', views.remove_bookmark, name='remove_bookmark'), diff --git a/newsaggregator/core/views.py b/newsaggregator/core/views.py index d56f3b2..9b74bc5 100644 --- a/newsaggregator/core/views.py +++ b/newsaggregator/core/views.py @@ -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 @@ -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@gmail.com'], 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): diff --git a/newsaggregator/db.sqlite3 b/newsaggregator/db.sqlite3 index 7a5fb8e..d4ef1d1 100644 Binary files a/newsaggregator/db.sqlite3 and b/newsaggregator/db.sqlite3 differ diff --git a/newsaggregator/newsaggregator/__pycache__/__init__.cpython-312.pyc b/newsaggregator/newsaggregator/__pycache__/__init__.cpython-312.pyc index 128f762..00e92fa 100644 Binary files a/newsaggregator/newsaggregator/__pycache__/__init__.cpython-312.pyc and b/newsaggregator/newsaggregator/__pycache__/__init__.cpython-312.pyc differ diff --git a/newsaggregator/newsaggregator/__pycache__/settings.cpython-312.pyc b/newsaggregator/newsaggregator/__pycache__/settings.cpython-312.pyc index 80f9a15..e74a9c8 100644 Binary files a/newsaggregator/newsaggregator/__pycache__/settings.cpython-312.pyc and b/newsaggregator/newsaggregator/__pycache__/settings.cpython-312.pyc differ diff --git a/newsaggregator/newsaggregator/__pycache__/urls.cpython-312.pyc b/newsaggregator/newsaggregator/__pycache__/urls.cpython-312.pyc index a27a33d..65cb305 100644 Binary files a/newsaggregator/newsaggregator/__pycache__/urls.cpython-312.pyc and b/newsaggregator/newsaggregator/__pycache__/urls.cpython-312.pyc differ diff --git a/newsaggregator/newsaggregator/__pycache__/wsgi.cpython-312.pyc b/newsaggregator/newsaggregator/__pycache__/wsgi.cpython-312.pyc index 4ffbe01..767972b 100644 Binary files a/newsaggregator/newsaggregator/__pycache__/wsgi.cpython-312.pyc and b/newsaggregator/newsaggregator/__pycache__/wsgi.cpython-312.pyc differ diff --git a/newsaggregator/newsaggregator/settings.py b/newsaggregator/newsaggregator/settings.py index ddde4f5..826d813 100644 --- a/newsaggregator/newsaggregator/settings.py +++ b/newsaggregator/newsaggregator/settings.py @@ -40,6 +40,7 @@ 'jazzmin', 'django.contrib.admin', 'django.contrib.auth', + 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', diff --git a/newsaggregator/newsaggregator/urls.py b/newsaggregator/newsaggregator/urls.py index 51365de..342f8fd 100644 --- a/newsaggregator/newsaggregator/urls.py +++ b/newsaggregator/newsaggregator/urls.py @@ -5,4 +5,5 @@ path('admin/', admin.site.urls), path('user/',include('userauths.urls')), path('',include('core.urls')), + ] diff --git a/newsaggregator/templates/core/contact.html b/newsaggregator/templates/core/contact.html index 07fe277..c4ebd23 100644 --- a/newsaggregator/templates/core/contact.html +++ b/newsaggregator/templates/core/contact.html @@ -10,6 +10,12 @@

+ {%for msg in messages%} + + + {%endfor%}

Contact Me

@@ -21,26 +27,34 @@

Contact Me

{% csrf_token %}
-
- {{form.name}} +
+ + +
+ +
+ +
-
- {{form.email}} -
-
- {{form.phone}} -
-
-
-
- {{form.content}} +
+
+ + +
-
+
+
+ + -
+ +
@@ -48,6 +62,7 @@

Contact Me

+ diff --git a/newsaggregator/userauths/__pycache__/__init__.cpython-312.pyc b/newsaggregator/userauths/__pycache__/__init__.cpython-312.pyc index cc9fcd6..9e5d88a 100644 Binary files a/newsaggregator/userauths/__pycache__/__init__.cpython-312.pyc and b/newsaggregator/userauths/__pycache__/__init__.cpython-312.pyc differ diff --git a/newsaggregator/userauths/__pycache__/admin.cpython-312.pyc b/newsaggregator/userauths/__pycache__/admin.cpython-312.pyc index 02b2328..30b5516 100644 Binary files a/newsaggregator/userauths/__pycache__/admin.cpython-312.pyc and b/newsaggregator/userauths/__pycache__/admin.cpython-312.pyc differ diff --git a/newsaggregator/userauths/__pycache__/apps.cpython-312.pyc b/newsaggregator/userauths/__pycache__/apps.cpython-312.pyc index f05d0f3..2c7b4a1 100644 Binary files a/newsaggregator/userauths/__pycache__/apps.cpython-312.pyc and b/newsaggregator/userauths/__pycache__/apps.cpython-312.pyc differ diff --git a/newsaggregator/userauths/__pycache__/forms.cpython-312.pyc b/newsaggregator/userauths/__pycache__/forms.cpython-312.pyc index bb860a6..0d17cc1 100644 Binary files a/newsaggregator/userauths/__pycache__/forms.cpython-312.pyc and b/newsaggregator/userauths/__pycache__/forms.cpython-312.pyc differ diff --git a/newsaggregator/userauths/__pycache__/models.cpython-312.pyc b/newsaggregator/userauths/__pycache__/models.cpython-312.pyc index c375134..1d3a80a 100644 Binary files a/newsaggregator/userauths/__pycache__/models.cpython-312.pyc and b/newsaggregator/userauths/__pycache__/models.cpython-312.pyc differ diff --git a/newsaggregator/userauths/__pycache__/urls.cpython-312.pyc b/newsaggregator/userauths/__pycache__/urls.cpython-312.pyc index 79fcd54..bc6e29c 100644 Binary files a/newsaggregator/userauths/__pycache__/urls.cpython-312.pyc and b/newsaggregator/userauths/__pycache__/urls.cpython-312.pyc differ diff --git a/newsaggregator/userauths/__pycache__/views.cpython-312.pyc b/newsaggregator/userauths/__pycache__/views.cpython-312.pyc index b59fa9a..6080ef4 100644 Binary files a/newsaggregator/userauths/__pycache__/views.cpython-312.pyc and b/newsaggregator/userauths/__pycache__/views.cpython-312.pyc differ diff --git a/newsaggregator/userauths/migrations/__pycache__/0001_initial.cpython-312.pyc b/newsaggregator/userauths/migrations/__pycache__/0001_initial.cpython-312.pyc index e180827..9e02f13 100644 Binary files a/newsaggregator/userauths/migrations/__pycache__/0001_initial.cpython-312.pyc and b/newsaggregator/userauths/migrations/__pycache__/0001_initial.cpython-312.pyc differ diff --git a/newsaggregator/userauths/migrations/__pycache__/__init__.cpython-312.pyc b/newsaggregator/userauths/migrations/__pycache__/__init__.cpython-312.pyc index 62e9755..b165916 100644 Binary files a/newsaggregator/userauths/migrations/__pycache__/__init__.cpython-312.pyc and b/newsaggregator/userauths/migrations/__pycache__/__init__.cpython-312.pyc differ