Make the Class list publicly available, add Class Feed page
This commit is contained in:
parent
e6aaef9bf1
commit
987e2a7465
|
@ -230,7 +230,7 @@ class CardViewSet(Base, Create, Retrieve, Update, Destroy):
|
||||||
|
|
||||||
|
|
||||||
class CourseViewSet(Base, List, Retrieve, Create, Update):
|
class CourseViewSet(Base, List, Retrieve, Create, Update):
|
||||||
permission_classes = [AllowMetadata | IsAuthenticated, IsAdminOrReadOnly | IsInstructorOrReadOnly]
|
permission_classes = [AllowMetadata | IsAuthenticatedOrReadOnly, IsAdminOrReadOnly | IsInstructorOrReadOnly]
|
||||||
queryset = models.Course.objects.annotate(date=Max('sessions__datetime')).order_by('-date')
|
queryset = models.Course.objects.annotate(date=Max('sessions__datetime')).order_by('-date')
|
||||||
|
|
||||||
def get_serializer_class(self):
|
def get_serializer_class(self):
|
||||||
|
@ -241,7 +241,7 @@ class CourseViewSet(Base, List, Retrieve, Create, Update):
|
||||||
|
|
||||||
|
|
||||||
class SessionViewSet(Base, List, Retrieve, Create, Update):
|
class SessionViewSet(Base, List, Retrieve, Create, Update):
|
||||||
permission_classes = [AllowMetadata | IsAuthenticated, IsAdminOrReadOnly | IsInstructorOrReadOnly]
|
permission_classes = [AllowMetadata | IsAuthenticatedOrReadOnly, IsAdminOrReadOnly | IsInstructorOrReadOnly]
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
if self.action == 'list':
|
if self.action == 'list':
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { Admin } from './Admin.js';
|
||||||
import { Paste } from './Paste.js';
|
import { Paste } from './Paste.js';
|
||||||
import { Sign } from './Sign.js';
|
import { Sign } from './Sign.js';
|
||||||
import { Courses, CourseDetail } from './Courses.js';
|
import { Courses, CourseDetail } from './Courses.js';
|
||||||
import { Classes, ClassDetail } from './Classes.js';
|
import { ClassFeed, Classes, ClassDetail } from './Classes.js';
|
||||||
import { Members, MemberDetail } from './Members.js';
|
import { Members, MemberDetail } from './Members.js';
|
||||||
import { Charts } from './Charts.js';
|
import { Charts } from './Charts.js';
|
||||||
import { Auth } from './Auth.js';
|
import { Auth } from './Auth.js';
|
||||||
|
@ -112,6 +112,12 @@ function App() {
|
||||||
<div className='content-wrap'>
|
<div className='content-wrap'>
|
||||||
<div className='content-wrap-inside'>
|
<div className='content-wrap-inside'>
|
||||||
|
|
||||||
|
<Switch>
|
||||||
|
<Route exact path='/classfeed'>
|
||||||
|
<ClassFeed />
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
<Route path='/'>
|
||||||
<Container>
|
<Container>
|
||||||
<div className='hero'>
|
<div className='hero'>
|
||||||
<Link to='/'>
|
<Link to='/'>
|
||||||
|
@ -243,6 +249,10 @@ function App() {
|
||||||
<Subscribe />
|
<Subscribe />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<Route exact path='/classes'>
|
||||||
|
<Classes token={token} />
|
||||||
|
</Route>
|
||||||
|
|
||||||
{user && user.member.set_details ?
|
{user && user.member.set_details ?
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path='/account'>
|
<Route path='/account'>
|
||||||
|
@ -271,6 +281,7 @@ function App() {
|
||||||
<Route path='/courses/:id'>
|
<Route path='/courses/:id'>
|
||||||
<CourseDetail token={token} user={user} />
|
<CourseDetail token={token} user={user} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<Route path='/courses'>
|
<Route path='/courses'>
|
||||||
<Courses token={token} user={user} />
|
<Courses token={token} user={user} />
|
||||||
</Route>
|
</Route>
|
||||||
|
@ -278,9 +289,6 @@ function App() {
|
||||||
<Route path='/classes/:id'>
|
<Route path='/classes/:id'>
|
||||||
<ClassDetail token={token} user={user} refreshUser={refreshUser} />
|
<ClassDetail token={token} user={user} refreshUser={refreshUser} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path='/classes'>
|
|
||||||
<Classes token={token} />
|
|
||||||
</Route>
|
|
||||||
|
|
||||||
<Route path='/members/:id'>
|
<Route path='/members/:id'>
|
||||||
<MemberDetail token={token} user={user} />
|
<MemberDetail token={token} user={user} />
|
||||||
|
@ -312,6 +320,8 @@ function App() {
|
||||||
}
|
}
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
|
</Route>
|
||||||
|
</Switch>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -50,6 +50,43 @@ function ClassTable(props) {
|
||||||
|
|
||||||
let classesCache = false;
|
let classesCache = false;
|
||||||
|
|
||||||
|
export function ClassFeed(props) {
|
||||||
|
const [classes, setClasses] = useState(classesCache);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const get = async() => {
|
||||||
|
requester('/sessions/', 'GET', '')
|
||||||
|
.then(res => {
|
||||||
|
setClasses(res.results);
|
||||||
|
classesCache = res.results;
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
get();
|
||||||
|
const interval = setInterval(get, 60000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<p/>
|
||||||
|
|
||||||
|
<Header size='large'>Upcoming Protospace Classes</Header>
|
||||||
|
|
||||||
|
{classes ?
|
||||||
|
<ClassTable classes={classes.filter(x => x.datetime > now).sort((a, b) => a.datetime > b.datetime ? 1 : -1)} />
|
||||||
|
:
|
||||||
|
<p>Loading...</p>
|
||||||
|
}
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export function Classes(props) {
|
export function Classes(props) {
|
||||||
const [classes, setClasses] = useState(classesCache);
|
const [classes, setClasses] = useState(classesCache);
|
||||||
const { token } = props;
|
const { token } = props;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user