Skip to content

Instantly share code, notes, and snippets.

View chrisjakuta's full-sized avatar

Christopher Johnson chrisjakuta

View GitHub Profile
from os import name
from django.db import models
#from django.contrib.auth.models import User
#this is the user model with my desire fields
# Create your models here.
class User(models.Model):
name = models.CharField(max_length=200, null=True, blank=True)
email = models.EmailField(max_length=200, null=True, blank=True)
occupation = models.CharField(max_length=200, null=True, blank=True)
@chrisjakuta
chrisjakuta / engineering_admin.py
Created July 25, 2021 01:25
Overriding the base admin template.
class EngineeringAdmin(AdminSite):
site_header = "Circulation Engineering Admin"
def get_urls(self):
urls = super().get_urls()
uda_gps_events_urls = [
url(
r'uda_gps_events/',
self.admin_view(
self.uda_gps_events_view
@chrisjakuta
chrisjakuta / email_message.py
Created April 10, 2021 02:15
A class that will store all of the necessary data to send a user an email. Prototype stage. The model included is a proxy model designed to save the email information about to be sent.
from django.core.mail import send_mail, send_mass_mail, EmailMultiAlternatives
from emailapp.models import SendIntroSignUpEmailModel, SendEmailModel
from django.template.loader import render_to_string, get_template
class SendEmailMessage:
def __init__(self, **kwargs):
if not kwargs['email']:
raise ValueError('Please include an object instance of SendEmailModel named email.')
@chrisjakuta
chrisjakuta / views.py
Created April 10, 2021 02:06
A Django view that will create a new user.
class UserCreateView(generics.CreateAPIView):
parser_class = (FileUploadParser, FormParser, MultiPartParser)
serializer_class = UserFrontendSerializer
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
@chrisjakuta
chrisjakuta / BlogPage.jsx
Last active April 10, 2020 01:03
Blog Detail Page
import React, { useEffect, useState } from 'react'
import { Wave } from 'better-react-spinkit'
// now-ui views
import ProfilePageHeader from '../components/Headers/ProfilePageHeader'
import IndexNavbar from '../components/Navbars/IndexNavbar'
import DarkFooter from '../components/Footers/DarkFooter'
// Reactstrap components
import React, { useState } from "react"
// localhost
import { localhost } from '../../backendConstants'
// components
import CreateAccountModal from '../../components/Modals/CreateAccountModal'
import NeedHelpModal from '../../components/Modals/NeedHelpModal'
// third party packages
@chrisjakuta
chrisjakuta / App.jsx
Last active April 13, 2020 18:43
App component
import React, { Component } from 'react'
import { Route, Switch, Redirect } from "react-router-dom"
// now-ui import
import LoginPage from './examples/LoginPage'
import Index from './Index'
// user developed views
import HomePage from './HomePage'
import BlogPage from './BlogPage'
@chrisjakuta
chrisjakuta / BlogListGroup.jsx
Created April 6, 2020 05:22
How to pass cached data to the Route component so it can render without a call to the backend.
import React, { useState, useEffect } from 'react'
import { ChasingDots } from 'better-react-spinkit'
// reactstrap components
import {
Container,
Card,
CardBody,
Row,
Col,
import React, { useState, useEffect } from "react"
// reactstrap components
import {
Collapse,
DropdownToggle,
DropdownMenu,
DropdownItem,
UncontrolledDropdown,
NavbarBrand,