Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayjain18 committed Jul 31, 2024
1 parent 57d23d8 commit 18fc472
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
8 changes: 7 additions & 1 deletion creator/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def dashboard(request):
response = generate_response(ig_username, industry, niche, about_ig_page, weeks)
if response.startswith("```html") and response.endswith("```"):
response = response[7:-3] # Remove the leading and trailing markdown code blocks
messages.success(request, "Content plan generated successfully")
messages.success(request, "Content plan generated successfully. Scroll down to bottom to view the plan.")
input_context = f"IG Username: {ig_username}\nIndustry: {industry}\nNiche: {niche}\nAbout IG Page: {about_ig_page}\nWeeks: {weeks}"
ContentGeneration.objects.create(email=request.user.email, input_context=input_context, content_output=response).save()
return render(request, 'dashboard.html', {'response': response})
Expand All @@ -51,6 +51,12 @@ def history(request):
@login_required(login_url='/signin/')
def download_content(request, content_id):
content_generation = get_object_or_404(ContentGeneration, pk=content_id)

# Check if the logged-in user is the owner of the content
if content_generation.email != request.user.email:
messages.error(request, "You do not have permission to download this content.")
return redirect('/dashboard/') # Redirect to dashboard or appropriate page

content_html = content_generation.content_output

# Use BeautifulSoup to strip HTML tags
Expand Down
13 changes: 13 additions & 0 deletions templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@
<!-- ====== Banner Section Start -->
<div class="relative z-10 overflow-hidden pt-[60px] pb-[10px] md:pt-[130px] lg:pt-[60px] dark:bg-dark">

<!-- ====== Messages Section Start -->
{% if messages %}
<div class="container mt-4">
<div class="flex flex-col space-y-4">
{% for message in messages %}
<div class="p-4 text-white bg-blue-500 rounded-lg">
{{ message }}
</div>
{% endfor %}
</div>
</div>
{% endif %}
<!-- ====== Messages Section End -->

</div>
<!-- ====== Banner Section End -->
Expand Down
18 changes: 16 additions & 2 deletions templates/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
<nav id="navbarCollapse"
class="absolute right-4 top-full hidden w-full max-w-[250px] rounded-lg bg-white dark:bg-dark-2 py-5 shadow-lg lg:static lg:block lg:w-full lg:max-w-full lg:bg-transparent dark:lg:bg-transparent lg:py-0 lg:px-4 lg:shadow-none xl:px-6">
<ul class="justify-center lg:flex 2xl:ml-20">
<li class="relative group">
<li class="relative group text-primary">
<a href="/dashboard/"
class="flex py-2 mx-8 text-base font-medium ud-menu-scroll text-dark dark:text-white group-hover:text-primary lg:mr-0 lg:inline-flex lg:py-6 lg:px-0 lg:text-body-color dark:lg:text-dark-6">
class="flex py-2 mx-8 text-blue-500 text-base font-medium ud-menu-scroll group-hover:text-primary lg:mr-0 lg:inline-flex lg:py-6 lg:px-0 lg:text-body-color dark:lg:text-dark-6">
Dashboard
</a>
</li>
Expand All @@ -61,6 +61,7 @@
</a>
</li>
{% endif %}

<li class="relative group lg:hidden">
<a href="/logout/"
class="flex py-2 mx-8 text-base font-medium ud-menu-scroll text-dark dark:text-white group-hover:text-primary lg:mr-0 lg:ml-7 lg:inline-flex lg:py-6 lg:px-0 lg:text-body-color dark:lg:text-dark-6 xl:ml-10">
Expand Down Expand Up @@ -97,6 +98,19 @@
<!-- ====== Banner Section Start -->
<div class="relative z-10 overflow-hidden pt-[60px] pb-[10px] md:pt-[130px] lg:pt-[60px] dark:bg-dark">

<!-- ====== Messages Section Start -->
{% if messages %}
<div class="container mt-4">
<div class="flex flex-col space-y-4">
{% for message in messages %}
<div class="p-4 text-white bg-blue-500 rounded-lg">
{{ message }}
</div>
{% endfor %}
</div>
</div>
{% endif %}
<!-- ====== Messages Section End -->

</div>
<!-- ====== Banner Section End -->
Expand Down

0 comments on commit 18fc472

Please sign in to comment.