Skip to content

Commit

Permalink
Merge pull request #35 from arpithpm/34-add-versioning-of-prompts
Browse files Browse the repository at this point in the history
34 add versioning of prompts
  • Loading branch information
arpithpm authored Apr 24, 2023
2 parents 6ea2731 + 81aa436 commit a378111
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion promptbook/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from django.contrib import admin
from .models import Category, Prompt, Label, PromptLabel
from reversion.admin import VersionAdmin

# Register your models here.
@admin.register(Category)
class YourModelAdmin(VersionAdmin):
pass

admin.site.register([Category, Prompt, Label, PromptLabel])
admin.site.register([Prompt, Label, PromptLabel])
3 changes: 2 additions & 1 deletion promptbook/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
import reversion


class Profile(models.Model):
Expand Down Expand Up @@ -37,7 +38,7 @@ class Category(models.Model):
def __str__(self):
return self.name


@reversion.register()
class Prompt(models.Model):
text = models.TextField()
category = models.ForeignKey(Category, on_delete=models.DO_NOTHING)
Expand Down
2 changes: 1 addition & 1 deletion promptbook/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json

import reversion
from enum import Enum

from django.db import IntegrityError
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ pillow==9.5.0
psycopg2-binary==2.9.6
django-allauth==0.54.0
djangorestframework==3.14.0
python-dotenv==1.0.0
django-reversion==5.0.4
6 changes: 6 additions & 0 deletions vidura/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

from pathlib import Path
import os
from dotenv import load_dotenv

# load ENV and DJANGO_SETTINGS_MODULE from .env file
load_dotenv()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -80,6 +84,7 @@
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'rest_framework',
"reversion",
]

MIDDLEWARE = [
Expand All @@ -90,6 +95,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'reversion.middleware.RevisionMiddleware',
]

ROOT_URLCONF = 'vidura.urls'
Expand Down

0 comments on commit a378111

Please sign in to comment.