Skip to content

Commit 988c568

Browse files
Merge pull request #10 from ekonstantinidis/init-demo
Demo Project
2 parents 154d061 + 36aaf0e commit 988c568

File tree

22 files changed

+462
-3
lines changed

22 files changed

+462
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ __pycache__/
33

44
env/
55
djangorestframeworkdocs.egg-info/
6+
7+
demo/env/
8+
demo/db.sqlite3

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include README.md
22
include LICENSE
33

4-
recursive-include drfdocs/static *.js *.css *.png *.eot *.svg *.ttf *.woff
5-
recursive-include drfdocs/templates *.html
4+
recursive-include rest_framework_docs/static *.js *.css *.less *.png *.eot *.svg *.ttf *.woff
5+
recursive-include rest_framework_docs/templates *.html
66
recursive-exclude * __pycache__
77
recursive-exclude * *.py[co]

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Finally include the `rest_framework_docs` urls in your `urls.py`:
3838
url(r'^docs/', include('rest_framework_docs.urls')),
3939
]
4040

41+
### Development & Demo Project
42+
Included in this repo you can find the demo project(at `/demo`). It is a project with *Django* & *Django Rest Framework* that will allow you to work with this project. For more information on how you can set it up please readme the [README.md](demo/README.md) of the demo project.
43+
4144
### Settings
4245

4346
REST_FRAMEWORK_DOCS = {

demo/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Setting up the demo project
2+
A demo project to get you started with DRF docs development.
3+
4+
5+
### Installation
6+
7+
# Create the virtual environment
8+
pyvenv env
9+
10+
# Install requirements
11+
env/bin/pip install -r requirements.txt
12+
13+
# Install Django Rest Framework Docs
14+
env/bin/pip install -e ../
15+
16+
# Run the project
17+
env/bin/python manage.py runserver
18+
19+
**Note**: You **do not** need a database or to run `migrate`.
20+
21+
22+
### Viewing DRF Docs
23+
Once you install and run the project go to [http://0.0.0.0:8000/docs/](http://0.0.0.0:8000/docs/).
24+
25+
26+
### Note
27+
The demo project has no functionality at all. Its purpose is **only** for viewing the docs and developing DRF docs further.

demo/manage.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
7+
8+
from django.core.management import execute_from_command_line
9+
10+
execute_from_command_line(sys.argv)

demo/project/__init__.py

Whitespace-only changes.

demo/project/accounts/__init__.py

Whitespace-only changes.

demo/project/accounts/models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from django.db import models
2+
from django.contrib.auth.models import AbstractBaseUser
3+
4+
5+
class User(AbstractBaseUser):
6+
created = models.DateTimeField(auto_now_add=True, db_index=True)
7+
modified = models.DateTimeField(auto_now=True)
8+
9+
email = models.EmailField(unique=True, verbose_name='email address', max_length=255)
10+
full_name = models.CharField(max_length=255)
11+
12+
is_active = models.BooleanField(default=False)
13+
is_admin = models.BooleanField(default=False)
14+
15+
USERNAME_FIELD = 'email'
16+
REQUIRED_FIELDS = ['email', 'full_name']

demo/project/accounts/serializers.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from rest_framework import serializers
2+
from project.accounts.models import User
3+
4+
5+
class UserRegistrationSerializer(serializers.ModelSerializer):
6+
7+
class Meta:
8+
model = User
9+
fields = ('email', 'full_name', 'password',)
10+
extra_kwargs = {'password': {'write_only': True}}
11+
12+
13+
class UserProfileSerializer(serializers.ModelSerializer):
14+
15+
class Meta:
16+
model = User
17+
fields = ('email', 'full_name', 'password', 'is_active')
18+
extra_kwargs = {
19+
'password': {'write_only': True}
20+
}
21+
read_only_fields = ('is_active',)
22+
23+
24+
class ResetPasswordSerializer(serializers.ModelSerializer):
25+
26+
id = serializers.CharField()
27+
token = serializers.CharField()
28+
29+
class Meta:
30+
model = User
31+
fields = ('id', 'token', 'password',)
32+
extra_kwargs = {'password': {'write_only': True}}

demo/project/accounts/urls.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from django.conf.urls import url
2+
from project.accounts import views
3+
4+
5+
urlpatterns = [
6+
url(r'^test/$', views.TestView.as_view(), name="test-view"),
7+
8+
url(r'^login/$', views.LoginView.as_view(), name="login"),
9+
url(r'^register/$', views.UserRegistrationView.as_view(), name="register"),
10+
url(r'^reset-password/$', view=views.PasswordResetView.as_view(), name="reset-password"),
11+
url(r'^reset-password/confirm/$', views.PasswordResetConfirmView.as_view(), name="reset-password-confirm"),
12+
13+
url(r'^user/profile/$', views.UserProfileView.as_view(), name="profile"),
14+
15+
]

0 commit comments

Comments
 (0)