Skip to content

Conversation

DimLight1998
Copy link

No description provided.

# Create your views here.

# 登录
class adminLogin(APIView):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name should use PascalCase.

def get(self):
# if self.request.user.is_authenticated():
activity_List = []
activites = Activity.objects.all()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use built-in objects filtering functions of django?

ticket_List = Ticket.objects.filter(activity=activity)
bookedTickets = 0
usedTickets = 0
for t in ticket_List:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use built-in counting functions of django?

raise ValidateError('Not found')
activity = activity_list[0]
if(activity.status != Activity.STATUS_PUBLISHED):
raise ValidateError("活动已截止")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a ValidateError?

for index in image.chunks():
f.write(index)
f.close()
return SITE_DOMAIN + '/img/activityImage/' + image.name
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use os.path.join.


allActs = Activity.objects.all()
for a in allActs:
if a not in acts:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use built-in functions.

unique_id = uuid.uuid5(uuid.NAMESPACE_DNS,self.user.student_id + activity.name + str(currentTime))
Ticket.objects.create(student_id = self.user.student_id, unique_id = unique_id,
activity = activity, status = Ticket.STATUS_VALID)
activity.remain_tickets -= 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use lock.

def reply_news(self, articles):
if len(articles) > 10:
self.logger.warn('Reply with %d articles, keep only 10', len(articles))
if len(articles) > 8:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move 8 to a variable.

Copy link
Author

@DimLight1998 DimLight1998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No authenticating for admin.
  • Use unified naming convention.
  • Add to_json and create_from_json method to models to reduce meaningless code when get information of create object.
  • Don't comment code when committing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant